Hello Rich, On 4 Dez., 02:30, Rich Hickey <[EMAIL PROTECTED]> wrote: > needle is a strange name - what's the origin? expr is probably better.
I thought of it as needle, which we search in the haystack. But this comparison is not very good after a second thought. Changed needle to expr. > I think the expr should be passed second to the fn - in most cases > where it matters, that is a more useful default: Ok. Changed. > I almost whipped this up yesterday, but I got sidetracked thinking > about how best to provide a feature like Scheme's cond's =>. Do you > know it? It feeds the value of the test to the fn on the rhs of the > clause. It can be useful. Yes. There were times I wanted that, but the pain wasn't big enough to make me implement it. I changed cond to expect either a vector or something else. The idea is to use the usual [var val] form for the binding. (cond [y (some #{:a :b :c} [:x :b :y])] (do-something-with y here) (normal-predicate form works as before) (y is different-here) :else works-also) For condp I attached the binding to the predicate definition. (condp [y some] [:x :b :y] #{:a :b :c} (do-something with y) #{:x :y :z} (same y here)) I think, using return value of the predicate basically depends on the latter. For "some" it may make sense, for "instance?" it is not very interesting. So I thought having to type one y is better than to repeat it in all the clauses. For cond it's different, because here the tests are independent. So it makes more sense to specify the binding explicitely. Of course, this still works: (condp = x 1 "A one" 2 "A two" "many") Since the web-interface doesn't allow attachments I will upload the patch in the files section to prevent clobbering of newlines and stuff. Sincerely Meikel --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---