Skip to content

Instantly share code, notes, and snippets.

@y2q-actionman
Created October 25, 2014 07:34
Show Gist options
  • Save y2q-actionman/e0c2ddb6fa7f2ab0f893 to your computer and use it in GitHub Desktop.
Save y2q-actionman/e0c2ddb6fa7f2ab0f893 to your computer and use it in GitHub Desktop.
cl:reduce で文字列として join する。
(defun join (lis &optional (sep " "))
(reduce #'(lambda (x y)
(concatenate 'string
(princ-to-string x) sep (princ-to-string y)))
lis))
#|
CL-USER> (defun join (lis &optional (sep " "))
(reduce #'(lambda (x y)
(concatenate 'string
(princ-to-string x) sep (princ-to-string y)))
lis))
JOIN
CL-USER> (join '(a b c d) "===")
"A===B===C===D"
CL-USER> (join '(a b c d) "=")
"A=B=C=D"
CL-USER> (join '(1 2 3 4) ",")
"1,2,3,4"
CL-USER>
|#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment