On Fri, Oct 14, 2011 at 5:50 PM, Alan Malloy <a...@malloys.org> wrote: > I really liked this one too, though my first draft of it was more like > (defn pipe [test f] > (fn [value] > (...))) ... > fix is basically your pipe, except it takes a series of test/f pairs, > and to-fix is my original version, returning a function of x instead > of computing on x immediately (this is handy as you can map (to-fix > string? read-string) over a collection, for example).
Out of curiosity, why wouldn't you define pipe to take [test f value] and then you can map (partial pipe string? read-string) over a collection? > Given accepts only one clause and is "shaped" right for use in -> > thread chains, like: > > (-> x > inc > (given even? / 2)) So it's given [value test f & args] yes? I'm finding quite often I want a function that's a bit like partial but puts the deferred arguments at the beginning of the argument list, let's call it impartial (j/k) so you could do: ((comp (impartial given even? / 2) inc) x) I know that's contrived but I'm finding #(f % args) common enough that something like "impartial" (with a better name, please!) would be useful in some sort of contrib library of higher-order functions. > If nothing else, I recommend you change the argument order to your > pipe function: (defn pipe [value test f]) is clearly the "correct" > signature, since it means that (like fix) you can use it in update-in/ > alter/swap!/-> chains. Ah, that answers my question above. Interesting point. Argument order choices are still something I'm learning new things about all the time! -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Railo Technologies, Inc. -- http://www.getrailo.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- 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