I was practicing writing macros and I can't seem to get defn
to work.
我正在练习编写宏,我似乎无法定义工作。
My syntax is: (my-define name parameter body)
我的语法是:(my-define name parameter body)
Ignoring & parameters and recursive routines, How do I bind the name to a (fn[parameter] body)?
忽略&参数和递归例程,如何将名称绑定到(fn [parameter] body)?
1 个解决方案
#1
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)))
#1
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)))