Created
October 25, 2014 07:34
-
-
Save y2q-actionman/e0c2ddb6fa7f2ab0f893 to your computer and use it in GitHub Desktop.
cl:reduce で文字列として join する。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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