Skip to content

Instantly share code, notes, and snippets.

@boolpath
Last active October 30, 2020 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boolpath/40bd4f263aca797640e64e51bfbc1065 to your computer and use it in GitHub Desktop.
Save boolpath/40bd4f263aca797640e64e51bfbc1065 to your computer and use it in GitHub Desktop.
hello-world-of-lisp-macros
(defmacro pass-args [code & args]
`(~@code ~@args))
> (macroexpand '(pass-args (+) 1 2 3))
(+ 1 2 3)
> (+)
0
> (pass-args (+) 1 2 3)
6
(defmacro pass-args (code &rest args)
`(,@code ,@args))
> (macroexpand '(pass-args (format) t "Hello, World!"))
(FORMAT T "Hello, World!")
T
> (pass-args (format) t "Hello, World!")
Hello, World!
NIL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment