Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defmacro def-functorC
- [fn-name fn-arg body]
- (let [context (gensym)
- b (if (coll? body) body (list body))]
- `(defn ~fn-name [[~context ~fn-arg]]
- (list ~context ~(map #(if (= % :context) context %) b)))))
- ;;in its current form
- (def-functorC my-fc
- arg
- arg)
- ;;fails since the "body" is just a single element
- ;but
- (def-functorC hello
- arg
- (reverse :context))
- ;;works since body is a collection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement