Last active
December 10, 2015 02:58
-
-
Save redraiment/4371489 to your computer and use it in GitHub Desktop.
Define a recursive lambda.
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
; dump tree with a recursive lambda | |
(funcall | |
(fn dump-tree (e) | |
(if (atom e) | |
(format t "~A~%" e) | |
(mapc #'dump-tree e))) | |
'(1 (2 (3 (4) 5) 6) 7 (8 9))) |
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
(defmacro fn (&rest body) | |
"(fn name? [param*] body) | |
Define a recursive lambda." | |
(if (listp (car body)) | |
`(lambda ,@body) | |
`(lambda (&rest args) | |
(labels (,body) | |
(apply (function ,(car body)) args))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment