Tutan Ramen Tutan Ramen - 1 year ago 142
Javascript Question

Point-free style capitalize function with Ramda

While writing a capitalize function is trivial, such that:

"hello" => "Hello"
"hi there" => "Hi there"

How would one write it using point-free style using Ramda JS?


Answer Source

It would be something like that:

const capitalize = R.compose(
    R.juxt([R.compose(R.toUpper, R.head), R.tail])

Demo: goo.gl/CJoP7V (it's a link to ramdajs.com REPL, stackoverflow does not allow posting links to goo.gl domain)