用 Ramda 大写字符串数组
Uppercase an array of strings with Ramda
我正在尝试使用 Ramda 制作一个点自由函数来将字符串数组大写,但我是新手并且无法正常工作。
const list = ['a', 'b', 'c', 'd', 'e']
const fn = R.compose(R.toUpper, R.map)
console.log('result', fn(list))
懂我Uncaught TypeError: function n(r){return 0===arguments.length||w(r)?n:t.apply(this,arguments)} does not have a method named "toUpperCase"
我也试过了
const fn = R.compose(R.toUpper, R.map(list))
console.log('result', fn())
但得到同样的错误。
我如何使用 Ramda 执行此操作?
你不需要作曲。 R.map
是柯里化的,所以你可以简单地用单个参数调用它
const fn = R.map(R.toUpper)
我正在尝试使用 Ramda 制作一个点自由函数来将字符串数组大写,但我是新手并且无法正常工作。
const list = ['a', 'b', 'c', 'd', 'e']
const fn = R.compose(R.toUpper, R.map)
console.log('result', fn(list))
懂我Uncaught TypeError: function n(r){return 0===arguments.length||w(r)?n:t.apply(this,arguments)} does not have a method named "toUpperCase"
我也试过了
const fn = R.compose(R.toUpper, R.map(list))
console.log('result', fn())
但得到同样的错误。
我如何使用 Ramda 执行此操作?
你不需要作曲。 R.map
是柯里化的,所以你可以简单地用单个参数调用它
const fn = R.map(R.toUpper)