Created
January 22, 2015 03:30
-
-
Save xieyuheng/f22e1a53653acf761c9c to your computer and use it in GitHub Desktop.
a cute CAT ^-^ in common lisp
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
(defmacro cat | |
((&key (to nil) | |
(trim '()) | |
prefix | |
postfix) | |
&body form#list-of-list) | |
(let* ((form#list-of-list#2 | |
(apply (function append) | |
(mapcar (lambda (list) | |
(list prefix | |
(list 'string-trim trim | |
(append '(format nil) list)) | |
postfix)) | |
form#list-of-list))) | |
(form#final (append '(concatenate (quote string)) | |
form#list-of-list#2))) | |
`(let ((string-for-return ,form#final)) | |
(format ,to "~A" string-for-return) | |
string-for-return))) | |
(cat (:to *standard-output* | |
:trim '(#\Space) | |
:prefix "* " | |
:postfix (cat () ("~%"))) | |
("~A" " 123 ") | |
("~A" " 456 ")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment