--- a/losh.asd Sat Nov 10 19:35:46 2018 -0500
+++ b/losh.asd Fri Nov 23 10:55:35 2018 -0500
@@ -47,6 +47,7 @@
"chili-dogs"))
(:file "sequences" :depends-on ("chili-dogs"
"hash-tables"
+ "functions"
"mutation"))
(:file "debugging" :depends-on ("control-flow"
"math"
--- a/package.lisp Sat Nov 10 19:35:46 2018 -0500
+++ b/package.lisp Fri Nov 23 10:55:35 2018 -0500
@@ -253,6 +253,7 @@
(defpackage :losh.sequences
(:use :cl :iterate :losh.quickutils
:losh.chili-dogs
+ :losh.functions
:losh.hash-tables
:losh.iterate-pre
:losh.mutation)
@@ -270,7 +271,8 @@
:drop-while
:summation
:product
- :doseq))
+ :doseq
+ :string-join))
(defpackage :losh.debugging
(:use :cl :iterate :losh.quickutils
--- a/src/sequences.lisp Sat Nov 10 19:35:46 2018 -0500
+++ b/src/sequences.lisp Fri Nov 23 10:55:35 2018 -0500
@@ -355,3 +355,18 @@
result))
+(defun string-join (separator sequence)
+ "Join a `sequence` of objects into a string, separated by `separator`.
+
+ All objects in `sequence` (and `separator`) will be `princ-to-string`ed before
+ joining.
+
+ This is implemented simply, not efficiently, so consider implementing your own
+ if you're joining a lot of stuff.
+
+ "
+ (unless (stringp separator)
+ (callf separator #'princ-to-string))
+ (flet ((concat (current next)
+ (concatenate 'string current separator next)))
+ (reduce (nullary #'concat "") sequence :key #'princ-to-string)))