Currying is a programming technique / transformation wherein an argument that takes one or more arguments is transformed into a chain of functions each taking precisely one argument. Some languages (e.g. ML, Haskell) require it.
Questions tagged [currying]
14 questions
182
votes
15 answers
What is the advantage of currying?
I just learned about currying, and while I think I understand the concept, I'm not seeing any big advantage in using it.
As a trivial example I use a function that adds two values (written in ML). The version without currying would be
fun add(x, y)…

Mad Scientist
- 2,766
- 2
- 18
- 19
15
votes
1 answer
Are chained methods that require only one parameter per method equivalent to currying?
I've been toying around with Ruby lately and I found myself wondering if in pure object oriented languages (and even those that are not pure) making methods that take only one parameter and then get chained together is equivalent to currying in…
user28988
14
votes
3 answers
Is it possible to have currying and variadic function at the same time?
I am thinking about making currying and variadic functions both available in a dynamically-typed functional programming language, but I wonder if it is possible or not.
Here are some pseudocode:
sum = if @args.empty then 0 else @args.head + sum…

Michael Tsang
- 810
- 2
- 7
- 13
12
votes
2 answers
A real-life example of using curry function?
I was struggled to find a real-life example of using curry function and get the benefit of using curry.
When I google curry function I often see the example like
let add = x => y => x + y;
let add10 = add(10);
console.log(add10(20));
I have to say…

Qiulang 邱朗
- 3,095
- 3
- 13
- 22
9
votes
4 answers
What's special about currying or partial application?
I've been reading articles on Functional programming everyday and been trying to apply some practices as much as possible. But I don't understand what is unique in currying or partial application.
Take this Groovy code as an example:
def mul = { a,…

Vigneshwaran
- 759
- 6
- 16
8
votes
2 answers
What is the difference between currying and partial function application in practice
I understand the difference between partial function application and a curried function (f(X x Y x Z) -> N vs f(X -> (Y -> (Z -> N)))), but I do not see what the consequence of this difference is when developing software.

Henk
- 191
- 4
7
votes
3 answers
Have they missunderstood currying or have I?
This question is similar to the question posted on Does groovy call partial application 'currying'?, but not completely the same, and the answers given there do not really satisfy me.
I would like to state right at this point, before I go any…

Buzu
- 171
- 2
4
votes
2 answers
Is currying too complex a tool to actually use?
Today I feel like I finally grokked currying (in Javascript), and of course, like any programmer who has learned a new trick, my mind immediately began racing over how to improve my current codebase using it.
And again, like any programmer, the…

Jason
- 2,037
- 2
- 17
- 16
2
votes
2 answers
Unknown number of arguments in currying
Hypothetical situation - can a currying function have an unknown number of arguments (kind of like varargs)
Eg in Python:
addByCurrying(1)(2)(3)(4)
Should equal 10
addByCurrying(5)(6)
Should equal 11
How could I implement it?

vikarjramun
- 353
- 2
- 9
2
votes
1 answer
Why use tuples as function parameters in languages that support currying?
In languages that support currying, I can't think of many cases where using a tuple as function input parameters would be better than breaking the tuple apart into multiple parameters, which then allows you to enjoy the full power of currying. In…

xji
- 771
- 1
- 6
- 14
2
votes
1 answer
The difference between bind and _.curry
So JavaScript's bind supports currying, but most people use some other library like lodash or ramda to do currying.
From first impression It seems like bind supports context changing, since that is it's intended role, e.g.
var replaceTest =…

knownasilya
- 3,074
- 3
- 17
- 16
2
votes
2 answers
Functional Programming style: How to write functions - explicit currying, implicit currying or lamdas?
So I have been using F# for a while and studying a bit of Haskell on the side and I have realized I could rewrite the exact same function one of three different ways.
Either with implicit currying, explicit currying, or with lambda…

Alexander Ryan Baggett
- 297
- 3
- 10
0
votes
3 answers
Equivalent to currying for return values
There are languages for which functions take exactly one argument and return one argument. This is nice and symmetrical, and there is no need to accept more than one argument because we can use currying: If we want a a function to take two…

ctrl-alt-delor
- 570
- 4
- 9
0
votes
2 answers
What is the advantage of global functions when writing functional code
I am a Swift developer and am trying to adopt a functional / reactive style in my code. I have been using ReactiveCocoa in all my projects and I have started giving RAC 3.0 a try. One thing I have seen is that in project, there is heavy use of…

villy393
- 109
- 3