summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2022-11-04 00:40:17 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2022-11-04 00:40:17 -0300
commita0bcb57cbcfbfa8070ee617056983b03e8e64c29 (patch)
tree478181d36dd875c542c10c5dd2fac2dba940957d
parentca2362bc53b548c1e0b2a725545984854fe62413 (diff)
downloadutils-a0bcb57cbcfbfa8070ee617056983b03e8e64c29.tar.gz
utils-a0bcb57cbcfbfa8070ee617056983b03e8e64c29.zip
Add str:from-list
-rw-r--r--package.lisp1
-rw-r--r--str.lisp10
2 files changed, 11 insertions, 0 deletions
diff --git a/package.lisp b/package.lisp
index de145ed..ddf77ea 100644
--- a/package.lisp
+++ b/package.lisp
@@ -10,4 +10,5 @@
(defpackage #:str
(:use #:cl)
(:export #:split
+ #:from-list
#:read-file))
diff --git a/str.lisp b/str.lisp
index e099e26..cbd6fe3 100644
--- a/str.lisp
+++ b/str.lisp
@@ -19,3 +19,13 @@
(length input)))
(queue:add result (subseq input start next)))))
(queue:to-list (split-rec (queue:new) 0)))
+
+(declaim (ftype (function ((cons char)) (values simple-string) &optional)) from-list)
+(defun from-list (lst)
+ (let ((str (make-string (length lst)))
+ (i 0))
+ (dolist (item lst)
+ (setf (char str i) item)
+ (incf i))
+ str))
+