Robert Tweed <fistful.of.spann...@gmail.com> writes:
> In writing this, I thought I'd better also test what (>) and (<) evaluate to, > because by the above definition, those should also evaluate to true. > Unfortunately, at least in v1.6, they throw an arity error. IMO, by the same > logic that says a single argument is valid, no arguments should be valid too. > Consider the following perfectly valid use-case: > > (def in-order? #(apply > %)) ; Seems obviously correct, no? > > (def items []) ; Maybe get this from a database; might be empty > > (in-order? items) ; Oops! > > ; ArityException Wrong number of args (0)... > > > This should perhaps be considered a bug. I suppose it depends on your > definition of "in order" for an empty set, but if we say that the most > sensible definition is based on whether the invariant "sort(x)=x" holds true, > then true is the correct result for the empty set. I agree that according to the docstring, "Returns non-nil if nums are in monotonically decreasing order, otherwise false." then both: (>) (<) should return non-nil since the numbers are in monotonicaly decreasing order. This is what is known as a correct, but uncooperative answer. So wrt the definition, the zero-arg call is special cased (i.e. it throws an arity exception). So, why not special case 1 arg as well, and have that except? It's a reasonable question. I would submit a bug report and see if anyone else agrees. Something is wrong for sure. Either (> x) should throw arity, or (>) should return true, or the docstring should be changed to note the special case for (>). Phil -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.