I wrote a poll to see what people what people’s preference was concerning functional composition.
currying
All posts tagged currying
If you have seen my most recent post about explicit currying in python, you may remember that I hadn’t bothered to wrap my head around trying to use keyword or default arguments. Also, as the title of my article stated, you had to very explicitly design the function to be curried, instead of having something reusable.
Well, some people cleverer than me took a good whack at it and here’s what they’ve got:
Currying in Python – from the Computer Science blog. He goes over every step of the way towards making a function that could be used as a decorator (though he doesn’t seem to know what a decorator is; he’s new to python) to transform normal functions into curried functions. It’s not especially pythonically written (again, he’s new to the language), and it’s big, but it works.
and
KISS Python Curry – a github python module by
Last week, I talked about currying a little bit, and I’ve been thinking about how one could do in languages that don’t have it built in. It can be done in Java, but the type of even a two-parameter function would be something like Function<Integer, Function<Integer, Integer>>, which is bad enough. Imagine 3- or 4-parameter functions.
There’s also the fact that calling curried functions doesn’t look good. Calling the two-parameter function with both parameters would look something like func.apply(1).apply(2). This isn’t what we want. At worst, we want to be stuck with func(1)(2), but that’s not possible in Java. At best, we want to be able to choose func(1)(2) (calling it with the first argument at one point in time and using the second one later) OR func(1, 2), depending on our current need. It’s possible to do so in python, so I’m using that. Continue Reading



