-
Notifications
You must be signed in to change notification settings - Fork 4
Turtle Kitty edited this page Jan 28, 2016
·
3 revisions
The quasiquote operator behaves like quote, but allows for the insertion of values. It is, in essence, a data structure template. Items within a qq are quoted unless unquoted with unq or unqs (unquote-splicing). unq splices a value into a list unchanged; unqs splices in the values of a list.
(def x "In Our Angelhood")
(def y '(foo bar baz))
(qq (x y (unq x) (unq y) (unqs y)))
-> (x y "In Our Angelhood" (foo bar baz) foo bar baz)
The percent (%), dollar ($), and at-sign (@) are syntactic sugar for qq, unq,and unqs, respectively. The template above can be written more tersely as:
%(x y $x $y @y)
-> (x y "In Our Angelhood" (foo bar baz) foo bar baz)