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!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to