Search This Blog

Tuesday, November 30, 2010

Syntax Quote: A Kata for the Confused.

;; Quote Unquote

;; For those having trouble with quote, eval, syntax quote, unquote, and splicing unquote, a kata:

;; Find a REPL, and type these forms in one by one.

;; Do not copy and paste them.

;; Type them. Into the REPL. One by one.

(def x '(* 3 5))

(def y (* 3 5)) 

x 

y 

(list 'println x (eval x) y) 

(list `println x (eval x) y) 

`(list println x (eval x) y) 

`(println x (eval x) y) 

`(println ~x (eval x) y)

`(println ~x ~(eval x) y)

`(println ~x ~(eval x) ~y)

`(println ~x ~(eval x) ~y ~@x)

;; Now play. Try variants of these expressions.

3 comments:

  1. YOU RULE. Thanks for this. Very straightforward and very helpful

    ReplyDelete
  2. Time passes, but that's still cool, thanks :).

    ReplyDelete

Followers