These are chat archives for ramda/ramda

30th
Jul 2018
Gary McAdam
@gpmcadam
Jul 30 2018 14:07
hi all. i'm looking for something similar to R.splitWhen, but rather than receiving a pair, it should repeat until the end of the List. Is there a nice way to achieve this?
Brad Compton (he/him)
@Bradcomp
Jul 30 2018 15:06
R.splitEvery
Is that what you mean?
Gary McAdam
@gpmcadam
Jul 30 2018 15:07
Hmm. No, that seems split into a specified length.

Suppose I have something like:

[ { type: 'command' }, { type: 'command }, { type: 'sep' }, { type: 'command' }, { type: 'command' }, { type: 'command }, { type: 'sep' }, { type: 'command' }, { type: 'command' }, { type: 'command' }, { type: 'command }, { type: 'sep' } ]

And I want it to split on type === 'sep' to end up with something like:

[ [ { type: 'command' }, { type: 'command } ], [ { type: 'command' }, { type: 'command' }, { type: 'command } ] , [ { type: 'command' }, { type: 'command' }, { type: 'command' }, { type: 'command } ] ]  ]
Brad Compton (he/him)
@Bradcomp
Jul 30 2018 15:09
I think the closest you'll get is R.splitOn
Gary McAdam
@gpmcadam
Jul 30 2018 15:10
I don't see documentation for R.splitOn in v0.25.0
Brad Compton (he/him)
@Bradcomp
Jul 30 2018 15:10
Nope, I thought it was a thing but it isn't
:expressionless:
Sorry :(
Gary McAdam
@gpmcadam
Jul 30 2018 15:12
Np. Thanks anyway! :)
Brad Compton (he/him)
@Bradcomp
Jul 30 2018 15:15
I think splitOn :: (a -> Bool) -> [a] -> [[a]] would be a really useful function.
So useful I thought it already existed lol
Brad Compton (he/him)
@Bradcomp
Jul 30 2018 15:21
Maybe splitWith is a good name...
Gary McAdam
@gpmcadam
Jul 30 2018 17:48
@Bradcomp Yep - agreed. I've raised a PR to add this: ramda/ramda#2620
Brad Compton (he/him)
@Bradcomp
Jul 30 2018 17:49
@gpmcadam Awesome!