On Feb 15, 8:10=A0pm, "Brian Mitchell" <binar... / gmail.com> wrote:
> On Fri, Feb 15, 2008 at 5:06 PM, Trans <transf... / gmail.com> wrote:
>
> > =A0On Feb 15, 12:46 pm, Yukihiro Matsumoto <m... / ruby-lang.org> wrote:
> > =A0> Hi,
>
> > =A0> In message "Re: Proc#curry"
>
> > > =A0 =A0 on Sat, 16 Feb 2008 02:35:23 +0900, Trans <transf... / gmail.com=
> writes:
>
> > =A0> |Is there a link where I can read about how this new function works=
?
>
> > =A0> [ruby-dev:33676], if you don't mind seeing Japanese ;-)
>
> > =A0> If you do mind, it's OK. =A0It's not difficult at all,
>
> > =A0> =A0 proc {|x, y, z| x + y + z }.curry
>
> > =A0> returns the proc object equivalent to
>
> > =A0> =A0 proc {|x| proc {|y| proc {|z| x + y + z } } }
>
> > =A0> See?
>
> > =A0Yep. I see.
>
> > =A0It is rather trivial, I agree. Unfortunately maybe too trivial becaus=
e
> > =A0were stuck with the order of arguments. Or doe curry take some
> > =A0argument to vary that? To clarify what I mean, Facets has an
> > =A0implementation of curry, for both Proc and Method, like so:
>
> > =A0 proc {|x, y, z| x + y + z }.curry(__,__,__)
>
> > =A0Of course I like your better in this case ;-) =A0BUT, it does allow:
>
> > =A0 proc {|x, y, z| x + y + z }.curry(__,5,__)
>
> > =A0for:
>
> > =A0 proc {|x| proc {|z| x + 5 + z } }
>
> Isn't that partial application not currying per say (one could curry
> as a way to implement partial application)?

I've also heard it called "partial currying". I'd rather have a
superset of funtionality then a subset. Currying is about isolating a
single argument. It doesn't dictate in which argument to isolate. It
could be x, y, or z, etc. Nor does it mean currying every variable all
the way down that line.

If we give matz's curry function an arity-slot number as an optional
argument, then we could do it all like so:

  P =3D proc { |x,y,z| x+y+z }
  P.curry(1) =3D> proc { |y| proc |x,z| x+y+z } }

Which would then allow partial applicaiton via:

 P.curry(1)[5]

A second argument could dictate the next level of currying

  P.curry(1,1) =3D> proc { |y| proc |z| proc |x| x+y+z } }

T.