On Mon, Mar 30, 2009 at 10:45 AM, Mark Engelberg <mark.engelb...@gmail.com> wrote: > I don't know whether this fix would be worth the performance penalty, > though, but it's what would "feel right" to me. >
If it's not practical to always reduce integers when used as keys, then I think it would be useful for a variation of clojure.lang.Numbers/reduce to be exposed as a common function in the API so that users can easily do their own reduction upon interop with Java, before storing in a hash-map or hash-set. Note that clojure.lang.Numbers/reduce does not accept a regular Integer as an input, so the API version should also cover that case, and just return the same Integer. I'm thinking num-reduce might be a good name. Maybe num-reduce could also convert float to double (doubles are what Clojure uses internally, right?). So basically, it would guarantee that your number is converted into Clojure's standard representation for that kind of thing so that it can be compared/hashed/etc. with Clojure's numeric computation results with no surprises. If something like this is not put in the API, I can add something like this to clojure.contrib.math, but it seems like it would be a generally valuable tool for numeric interop, and thus worthy of inclusion in the core. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---