views:

108

answers:

1

The code below doesn't behave as I would expect.

; given a function name, its args and body, create 2 versions:
; i.e., (double-it foo []) should create 2 functions: foo and foo*
(defmacro double-it             
  [fname args & body]       
  `(defn ~fname ~args ~@body) 
  `(defn ~(symbol (str fname "*")) ~args ~@body))

The code above doesn't create two functions as I would expect. It only creates the last one.

user=> (double-it deez [a b] (str b a))
#'user/deez*

How can I get a single macro to define two functions?

+10  A: 
Hamza Yerlikaya