ramda
ramda copied to clipboard
R.prepend and R.append should work for strings too (String → String → String)
R.concat
does work for strings.
R.concat(s)
or R.concat(R.__, s)
could be used instead, but I think R.prepend(s)
and R.append(s)
just sound better.
At least for me, they map more naturally to what I wanna do. For me, curried R.concat
is less readable than equivalent arrow function.
This, a few hours ago I spent some minutes looking for the right function for my module and the first choice in my head was to look for R.append
, and then I saw that there's no such thing for strings and had to spend a few minutes remembering that it's actually called R.concat
here and that it's actually inverted, so I had to invert the logic and direction of my pipes. It's a tad bit unintuitive if you ask me.
I make no guarantees that it would be approved, but I would be happy to see a PR for this.
IMHO using concat
for strings seems nicer and we already support that.
Just saying, changing append
definition to list.concat([el])
, ie. using .concat
instead of _concat
does enable it to concat strings due to JS's weak typing (I'm not saying that it's a good idea to rely on it). Found no similar trick for prepend
.
R.flip(R.concat) is a nice way of giving you both append and prepend equivalents