Skip to content

Instantly share code, notes, and snippets.

@redraiment
Last active December 10, 2015 02:58
Show Gist options
  • Save redraiment/4371489 to your computer and use it in GitHub Desktop.
Save redraiment/4371489 to your computer and use it in GitHub Desktop.
Define a recursive lambda.
; 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)))
(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