Message147918
> But so does functools.partial. So the question is, what use case does it
> help that functools.partial doesn't?
Sure, it's common `defining new functions on other functions`... more times. Here a stupid example with fold (our reduce).
@curry
def fold(function, start, sequence):
if len(sequence) == 0:
return start
else:
return fold(function, function(start, sequence[0]), sequence[1:])
Now, someone could be define a generic summer function by fold.
import operator as op
summer = fold(op.add)
Now, an other programmer could be use summer for defining listsummer (a function which sum only list), as follow.
listsummer = summer([])
In addition, curry is cleaver than functools.partial.
summer = functools.partial(fold, op.add)
listsummer = functools.partial(summer, [])
However, it is an additional feature. Nobody forces you to use it, but if you need it... Yeah, you could rewrite it each time, but why? It is perfect in functools (: |
|
Date |
User |
Action |
Args |
2011-11-18 19:38:15 | markonervo | set | recipients:
+ markonervo, collinwinter, rhettinger, pitrou, gregory_p, ezio.melotti, eric.araujo, alex, serprex |
2011-11-18 19:38:15 | markonervo | set | messageid: <1321645095.52.0.587027963.issue13430@psf.upfronthosting.co.za> |
2011-11-18 19:38:14 | markonervo | link | issue13430 messages |
2011-11-18 19:38:14 | markonervo | create | |
|