2010/1/15 C. Florian Ebeling <florian.ebel...@gmail.com>: > I agree. It only looks inconsistent when you assume nil is treated > uniformly by these comparison function, which does not make sense.
I quite often wish to compare comparable objects that are not numbers and wrote some simple operators to do that: user=> (<? \a \b \c) true user=> (<? \c \b) false user=> (<? 1 nil) false user=> (<? nil 1) true Which would work in your situation... However if you are using numbers but sometimes encounter nil, then a better solution would be to use fnil, which is a function that returns a function that will substitute any nil arguments with some default value. This is very handy shorthand when you have nil data points that you want to treat as zero: user=> ((fnil 0 0 <) nil 1) true user=> ((fnil 0 0 <) 1 nil) false You can find the implementation for both object comparator operators and fnil from my github if you are interested: http://github.com/timothypratley/strive/blob/master/clj/timothypratley/extensions.clj Regards, Tim.
-- 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 Note that posts from new members are moderated - please be patient with your first post. 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