Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defmacro def-functorC
  2.   [fn-name fn-arg body]
  3.   (let [context (gensym)
  4.         b (if (coll? body) body (list body))]
  5.     `(defn ~fn-name [[~context ~fn-arg]]
  6.        (list ~context ~(map #(if (= % :context) context %) b)))))
  7.  
  8. ;;in its current form
  9. (def-functorC my-fc
  10.                arg
  11.                arg)
  12. ;;fails since the "body" is just a single element
  13.  
  14. ;but
  15.  
  16. (def-functorC  hello
  17.                 arg
  18.   (reverse :context))
  19.  
  20. ;;works since body is a collection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement