【发布时间】:2019-06-05 17:15:12
【问题描述】:
我正在学习 JS 中的函数式编程,我正在使用 Ramda 进行学习。
我正在尝试制作一个接受参数并返回列表的函数。代码如下:
const list = R.unapply(R.identity);
list(1, 2, 3); // => [1, 2, 3]
现在我尝试使用pipe:
const otherList = R.pipe(R.identity, R.unapply);
otherList(1,2,3);
// => function(){return t(Array.prototype.slice.call(arguments,0))}
返回一个奇怪的函数。
这个:
const otherList = R.pipe(R.identity, R.unapply);
otherList(R.identity)(1,2,3); // => [1, 2, 3]
出于某种原因工作。
我知道这可能是一个新手问题,但是如果 f 是 unapply 而 g 是 identity,你将如何用 pipe 构造 f(g(x))?
【问题讨论】:
-
注意拼写是'Ramda',而不是'Rambda'。我已经为你编辑了。
标签: javascript functional-programming ramda.js function-composition