分支是柯里化的必要特征吗?

Is branching a required feature of currying?

在编写 curry 函数的实现时,是否需要能够分支?

Javascript中的用法示例:

var foo = function (a, b) { console.log(a, b); },
x = curry(foo),
y = x('bar'); // An example of branching

x('baz'); // -> 'bar baz'
y('qux'); // - > 'bar qux'

此处的示例显示我们第一次使用值 bar 调用柯里化函数并将结果函数存储在变量 y.

我的问题是:我们是否能够独立于应用于 x 的进一步操作(在本例中将 baz 作为下一个参数)。

如果你不确定柯里化是什么,维基百科是这样说的:

In mathematics and computer science, currying is the technique of translating the evaluation of a function that takes multiple arguments (or a tuple of arguments) into evaluating a sequence of functions, each with a single argument (partial application).

http://en.wikipedia.org/wiki/Currying

更新:

问这个问题的另一种方式是:柯里化函数是否应该简单地保持它的当前状态并且 return 除了应用最后一个参数时没有任何值,或者每次调用都应该导致 return 封装了所有先前应用的参数的新函数?

柯里化的通常含义是调用参数少于预期数量的函数将return一个预期剩余缺失参数的函数。

它应该在函数对象上累积状态...

f = curry(function(x, y, z) { return x+y+z; });

g = f(1)  // --> <func>
h = g(2)  // --> <func>
h(3)      // --> 6  (computed from 1+2+3)
g(10, 20) // --> 31 (computed from 1+10+20)

柯里化甚至用于您实际上没有可变状态概念的纯函数式语言。