On Dec 22, 12:39 am, Randall R Schulz <
rsch...@sonic.net> wrote:
> But I (the individual) agree, modulo a proper overloading pattern to
> afford minimal overhead for the two-argument form.
You mean like:
(defn bit-or
([] 0)
([x] x)
([x y] (clojure.lang.Numbers/or x y))
([x y & rest]
(reduce #(clojure.lang.Numbers/or %1 %2) (list* x y rest))))
(defn bit-and
([] 1)
([x] x)
([x y] (clojure.lang.Numbers/and x y))
([x y & rest]
(reduce #(clojure.lang.Numbers/and %1 %2) (list* x y rest))))
Btw. wouldn't it be handy if static Java methods could be handled
directly as functions? So the implementations would become:
(defn bit-or
([] 0)
([x] x)
([x y] (clojure.lang.Numbers/or x y))
([x y & rest]
(reduce clojure.lang.Numbers/or (list* x y rest))))
(defn bit-and
([] 1)
([x] x)
([x y] (clojure.lang.Numbers/and x y))
([x y & rest]
(reduce clojure.lang.Numbers/and (list* x y rest))))
Much clearer IMO.
Cheers!