Meikel Brandmeyer wrote: > Hi, > > Am 21.07.2009 um 22:48 schrieb Jimmie Houchin: > >> (defn is-small? [number] >> (if (< number 100) "yes" "no" )) >> >> Is is-small? a predicate? If so, is this a common pattern for such >> predicates? > > The definition is correct. is-small? is not > a predicate. It returns a string. So (if (is-small? x) ..) > is always true! I suspect that the string > produced by is-small? is used somewhere. > > (defn is-small? > [number] > (< number 100)) > > This would be a predicate since it returns > a Boolean. > > Hope this helps. > > Sincerely > Meikel
Thanks for the information. That is what I thought. Is it proper or idiomatic Clojure to use a "?" symbol on non-predicate functions? That is somewhat what prompted my question. If a "?" symbol is generally, always or primarily reserved for predicates, it just seemed strange to use a non-predicate example in the book. Especially when the example could just as easily used true or false, instead of yes or no. Thanks again. Jimmie --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---