7 ms·
I much prefer partial application. It just makes more intuitive sense - you take a function with many arguments, "fix" some of those arguments, and get a new fu
by yen223 3y ago
I much prefer partial application. It just makes more intuitive sense - you take a function with many arguments, "fix" some of those arguments, and get a new function out. No need to mess with argument ordering, or all that.
It's a shame the only language that did partial application well is, weirdly, Python.
- bPspGiJT8Y 3y agoIn Gleam it also seems to be done well: https://tour.gleam.run/functions/function-captures/ https://tour.gleam.run/functions/function-captures/
- IshKebab 3y agoPartial application just means fixing some arguments. My point was you can do that easily using lambda functions. I guess you were talking about `functools.partial`, which is basically the same as currying and also only works on the last arguments. It's better to use lambda functions. Also Python is far from the only language to have a function like that, e.g. see C++'s `std::bind` which nobody* uses since lambdas were supported. *standard HN disclaimer
- yen223 3y ago> I guess you were talking about `functools.partial`, which is basically the same as currying and also only works on the last arguments I was talking about `functools.partial` yes, but it can work on any arguments in order, using keyword arguments. e.g. def copy(source, dest): ..... copy_to_temp = partial(copy, dest="/tmp/") copy_from_temp = partial(copy, source="/tmp/")