These are chat archives for ramda/ramda

11th
Jul 2016
Gabe Johnson
@gabejohnson
Jul 11 2016 02:26
:thumbsup: @Avaq
Tushar Mathur
@tusharmath
Jul 11 2016 05:51
Can ramda support common operations such as filter & map on observables?
I am trying to work out an observable library that works well with Ramda.
James Forbes
@JAForbes
Jul 11 2016 07:11

@tusharmath if it has filter and map, Ramda will dispatch to it.

https://github.com/ramda/ramda/blob/v0.21.0/src/filter.js#L15

Aldwin Vlasblom
@Avaq
Jul 11 2016 07:55
@tusharmath I think most is 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.
James Forbes
@JAForbes
Jul 11 2016 08:30
flyd is my favourite, it supports fantasy land as well, but most is great too
Dejan Toteff
@selfrefactor
Jul 11 2016 09:53
@davidchambers R.toString I am using it to turn array of ["some string"] to "some string"
R.ifElse is used because there are some string with ":>" limiter and some are without
sourcevault
@sourcevault
Jul 11 2016 12:54
@JAForbes - Most.js is awesome ! :+1:
David Chambers
@davidchambers
Jul 11 2016 16:03

R.toString I am using it to turn array of ["some string"] to "some string"

That's not what it will do though, @selfrefactor.

@ram-bot
R.toString(["some string"])
ram-bot
@ram-bot
Jul 11 2016 16:03
'["some string"]'
David Chambers
@davidchambers
Jul 11 2016 16:06
As @xgrommx suggested, replace is the clearest approach as far as I'm concerned. ;)
Denis Stoyanov
@xgrommx
Jul 11 2016 18:21
@davidchambers =)
Rafe
@rjmk
Jul 11 2016 18:29

If you wanted to avoid regex, you could just use ">:" instead of @xgrommx's nice regex to the same effect as the original fn.

If avoiding 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.

David Chambers
@davidchambers
Jul 11 2016 19:21
The problem with split is the message may contain '>:'. We'd want to split once. A regexp allows us to do this.
Denis Stoyanov
@xgrommx
Jul 11 2016 19:27
@ram-bot
R.replace(/<[\w]+>:?/gi, '', '<allein stehend>: mehrere von ihnen')
ram-bot
@ram-bot
Jul 11 2016 19:27
'<allein stehend>: mehrere von ihnen'
Denis Stoyanov
@xgrommx
Jul 11 2016 19:27
oh
@ram-bot
R.replace(/<([\w ])+>:?/gi, '', '<allein stehend>: mehrere von ihnen')
ram-bot
@ram-bot
Jul 11 2016 19:30
' mehrere von ihnen'
Denis Stoyanov
@xgrommx
Jul 11 2016 19:31
@ram-bot
R.replace(/<([\w ])+>:\s?/gi, '', '<allein stehend>: mehrere von ihnen')
ram-bot
@ram-bot
Jul 11 2016 19:31
'mehrere von ihnen'
Denis Stoyanov
@xgrommx
Jul 11 2016 19:32
@ram-bot
R.replace(/<[\w ]+>:\s?/gi, '', '<allein stehend>: mehrere von ihnen')
ram-bot
@ram-bot
Jul 11 2016 19:32
'mehrere von ihnen'
Denis Stoyanov
@xgrommx
Jul 11 2016 19:32
:smile:
Denis Stoyanov
@xgrommx
Jul 11 2016 19:37
more general this regexp <[\w\s?]+>:\s?
but if you want only letters => <[a-zA-Z\s?]+>:\s?
Rob Halff
@rhalff
Jul 11 2016 21:32
If my main subject to be modified is a single object R.evolve is the most elegant main function right?
Rafe
@rjmk
Jul 11 2016 22:32

@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 R.ap(R.zip, R.tail)

Actually, that probably wouldn't work in JS without a split at the beginning and a join at the end
Denis Stoyanov
@xgrommx
Jul 11 2016 22:53
@rjmk overcomplicated
Rafe
@rjmk
Jul 11 2016 23:47
@xgrommx Agree