javascript - 使用 Ramda 使函数 pointfree

标签 javascript functional-programming ramda.js pointfree

我怎样才能使以下函数成为 pointfree(使用 Ramda)?

const prefixAll = R.curry((prefix, list) => R.map(R.concat(prefix), list))

最佳答案

此外,这应该有效

R.useWith(R.map, [R.concat, R.identity])

(R.identity is there for proper arity of the function, see @scott-sauyet's comment.)

see Ramda REPL

P.S:但我个人认为,compose 更好——使用参数的部分应用是更实用的方法。例如R.compose(R.map, R.concat)('a')(['a','b'])

关于javascript - 使用 Ramda 使函数 pointfree,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43869365/

相关文章:

javascript - Ramda - R.both 带有柯里化(Currying)谓词

javascript - 要求用户从调色板中选择一种颜色并通过 JavaScript 修改 SVG

javascript - 如何从 JSON 继承获取 JavaScript 对象?

javascript - 将具有逻辑和用户界面的函数转换为高阶函数

node.js - 使用字符串键和函数值定义对象的类型

javascript - 将数组对象展平为单个对象 - Javascript

angular - 找不到 'ramda' 的类型定义文件

javascript - 如何暂停网页上运行的所有内容?

javascript - jquery弹出jqModal多个对话框窗口

python - 偏函数的现实世界示例