functional 0.5 released
bonono at gmail.com
bonono at gmail.com
Sun Feb 12 01:27:30 EST 2006
Collin Winter wrote:
> On 10 Feb 2006 19:57:48 -0800, bonono at gmail.com <bonono at gmail.com> wrote:
> >
> > Collin Winter wrote:
> > > As always, feedback welcome!
> >
> > Any specific reason flip only flip the first 2 arguments rather than
> > the whole tuple ?
> >
> > That is, I would like to see:
> >
> > assert(f(a,b,c, d) == flip(f)(d, c, b, a))
>
> Because that's what I'm used to from Haskell and other functional
> languages : ) I'll see what I can do about having it flip all
> arguments in the next release.
>
Thanks for looking into it.
BTW, I do a quick test on the C version(supposed to be faster) and
found something interesting:
Your partial implementation is slower than new.instancemethod(func,
arg, object), may be you would like to have some micro optimization to
use that instead for the special case(and I believe over 70% of the
case) of :
partial(func, arg)
Another thing I am wondering is if a compose_m(which means
f(*g(*arg,**kw)) ) is desirable as that would give me a choice if I
want to expand the result of g(if it is a tuple) to multi-argument
rather than single tuple. This is not a problem in Haskell which is
fully curried but python in general is not. Another option may be a
helper function like unpack in lua. So I can do compose(compose(f,
unpack), g) which means f(unpack(g(*arg,**kw))).
More information about the Python-list
mailing list