tags:

views:

100

answers:

1

I was practicing writing macros and I can't seem to get defn to work.

My syntax is: (my-define name parameter body)

Ignoring & parameters and recursive routines, How do I bind the name to a (fn[parameter] body)?

+8  A: 

You will need to transform

(my-define <name> <args> <body>)

to

(def <name> (fn <args> <body>))

This is quite simple actually:

(defmacro my-define [name args body]
  `(def ~name (fn ~args ~body)))
Jonas