Search code examples
javascriptfunctional-programmingramda.jspointfree

Make function pointfree using Ramda


How can I make the following function pointfree (using Ramda)?

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

Solution

  • Also, this should work

    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: But I personally think, that compose is better – using partial application of argument is more functional approach. e.g. R.compose(R.map, R.concat)('a')(['a','b'])