Guest User

Untitled

a guest
Jan 20th, 2012
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defmacro defbinop [op zero]
  2.   `(do
  3.      (defmulti ~op nary-dispatch)
  4.      (defmethod ~op ::nullary [] ~zero)
  5.      (defmethod ~op ::n-ary
  6.        [~'x ~'y & ~'more]
  7.        (if ~'more
  8.          (recur (~op ~'x ~'y) (first ~'more) (next ~'more))
  9.          (~op ~'x ~'y)))
  10.      (defmethod ~op [:j-long :j-long]
  11.        [~'x ~'y]
  12.        (clojure.core/~op ~'x ~'y))))
Advertisement
Add Comment
Please, Sign In to add comment