Last active
November 11, 2017 08:58
-
-
Save shirok/20c63902b195b0e03a55ecf066ca30bf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
;; objsは文字列のリストに限らず任意のオブジェクトのリスト | |
(defun join (separator objs) | |
(format nil "~{~a~#,1^~a~}" (mapcan (lambda (s) (list s separator)) objs))) | |
;; separatorが固定なら多少わかりやすい。というかこのケースならformatを直接書くだろう。 | |
(defun join-by-comma (objs) | |
(format nil "~{~a~^, ~}" objs)) | |
#| | |
[6]> (join "-" '(tic tac toe)) | |
"TIC-TAC-TOE" | |
[7]> (join-by-comma '(tic tac toe)) | |
"TIC, TAC, TOE" | |
|# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment