These are chat archives for ramda/ramda
@tusharmath if it has filter and map, Ramda will dispatch to it.
mostis a great choice. It stands for MonadicStreams, and has thus been made with algebraic compliance in mind. Any library that supports Fantasy Land, including Ramda, will work nicely with it.
R.toString I am using it to turn array of ["some string"] to "some string"
That's not what it will do though, @selfrefactor.
replaceis the clearest approach as far as I'm concerned. ;)
If you wanted to avoid regex, you could just use ">:" instead of @xgrommx's nice regex to the same effect as the original fn.
replace entirely, as @davidchambers pointed out,
R.split always returns an array, so the
ifElse could be replaced with
R.lastin all cases. The
R.toString should probably be dropped.
splitis the message may contain
'>:'. We'd want to split once. A regexp allows us to do this.
R.replace(/<[\w]+>:?/gi, '', '<allein stehend>: mehrere von ihnen')
R.replace(/<([\w ])+>:?/gi, '', '<allein stehend>: mehrere von ihnen')
R.replace(/<([\w ])+>:\s?/gi, '', '<allein stehend>: mehrere von ihnen')
R.replace(/<[\w ]+>:\s?/gi, '', '<allein stehend>: mehrere von ihnen')
R.evolveis the most elegant main function right?
@davidchambers True! (Though the original fn has this problem too -- perhaps it's not an issue in the domain?)
Anyway, if you wanted to have the same behaviour and not use regexp (probably not a great idea), I think you could
let filterFn = msg => R.compose(R.tail, R.map(R.prop(1)), R.not, R.equals([">", ":"]), R.zip(msg, R.tail(msg)))
Or if you wanted to make it point free (probably an even worse idea), you could replace
R.zip(msg, R.tail(msg)) with