Skip to content

Instantly share code, notes, and snippets.

@nakkaya
Created August 8, 2017 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nakkaya/7050d5daf2c7034a25bb079658d8b2dc to your computer and use it in GitHub Desktop.
Save nakkaya/7050d5daf2c7034a25bb079658d8b2dc to your computer and use it in GitHub Desktop.
(defn +
"Returns the sum of nums. (+) returns 0. Does not auto-promote
longs, will throw on overflow. See also: +'"
{:inline (nary-inline 'add 'unchecked_add)
:inline-arities >1?
:added "1.2"}
([] 0)
([x] (cast Number x))
([x y] (. clojure.lang.Numbers (add x y)))
([x y & more]
(reduce1 + (+ x y) more)))
(defn +
([] 0)
([x] x)
([h v]
"__result = h.cast<number>()->add(v);")
([x y & more]
(reduce + (+ x y) more)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment