Ha, the argument order as written here was just off the top of my
head; when I look at where I actually use it, it's [test f value] like
Sean said, for use with partial.
That said, I like to-fix's brevity over using partial all the time.
Clojure makes it so easy to compose functions on the fly tha
On Oct 15, 1:23 am, Sean Corfield wrote:
> On Sat, Oct 15, 2011 at 12:59 AM, Alan Malloy wrote:
> > As you notice lower, I like this argument-order so that I can chain
> > operations on values better
>
> Yes.
>
> > But, that map is handy, so we have (to-fix), which is basically a
> > partial sett
On Sat, Oct 15, 2011 at 12:59 AM, Alan Malloy wrote:
> As you notice lower, I like this argument-order so that I can chain
> operations on values better
Yes.
> But, that map is handy, so we have (to-fix), which is basically a
> partial setting all *but* the first arg (tying nicely into what you
27;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.
Yeah, I've heard this from a few people. Myself, I don't think I run
in
partial" (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 mean
meantime, take useful for a spin, and see if the enhanced versions
of pipe are of any use to you.
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
One higher-order function I've found useful as I've goofed around with
clojure has been one that I made up myself, but it's proved so useful
and so simple that I have to believe it's in core somewhere:
(defn pipe [test value f]
(if (test value)
(f value)
value))
Is this a core f