These are chat archives for ramda/ramda

23rd
May 2016
hkrutzer
@hkrutzer
May 23 2016 16:48
how would I split [1,2,'marker',3,4,'marker',5,6] into [[1,2],[3,4],[5,6]]?
guess I'll reduce
Taylor Hurt
@thurt
May 23 2016 17:11
How about filter(is(Number))
@iamstarkov
May 23 2016 17:11
@hkrutzer R.splitBy
Taylor Hurt
@thurt
May 23 2016 17:15
pipe(filter(is(Number), splitEvery(2))
@iamstarkov
May 23 2016 17:18
I guess need to be splitter not every two, but every marker
Taylor Hurt
@thurt
May 23 2016 17:22
@iamstarkov probably right
Christian Bongiorno
@chb0github
May 23 2016 17:30
Hey all. Trying to wrap my head around some of the features/functions of Ramda; hoping someone can give me some ideas/input on the problem I am trying to solve
hkrutzer
@hkrutzer
May 23 2016 17:32
you mean splitWhen? thanks :D what about ['markerA',1,2,'markerB',3,4] into {markerA: [1,2], markerB: [3,4]}?
@iamstarkov
May 23 2016 17:43
Split by complement is number, objOf head
Split by complemented Is Number and map with objOf head and tail and mergeAll
/cc @hkrutzer
All of this within a pipe
Taylor Hurt
@thurt
May 23 2016 17:52
splitBy doesnt appear is documentation. Has it been removed?
*in
@iamstarkov
May 23 2016 17:57
splitWhen
Denis Stoyanov
@xgrommx
May 23 2016 18:49
Without Ramda
@ram-bot
const arr = ['markerA',1,2,'markerB',3,4,5,6];

const k = arr.map((x, i) => {
return typeof x === 'string' && /^marker/.test(x) && i
}).filter(x => /^\d\$/.test(x))

k.reduce((a, b, i, o) => {
return [].concat(a, {
[arr[b]]: arr.slice(b + 1, o[i + 1])
})
}, [])
ram-bot
@ram-bot
May 23 2016 18:49
[ { markerA: [ 1, 2 ] }, { markerB: [ 3, 4, 5, 6 ] } ]
Denis Stoyanov
@xgrommx
May 23 2016 18:50
@hkrutzer this is what do u want?
Denis Stoyanov
@xgrommx
May 23 2016 19:46
@ram-bot
const arr = ['markerA',1,2,'markerB',3,4,5,6];

const k = compose(
filter(is(Number)),
addIndex(map)((x, i) => is(String, x) && match(/marker/, x) && i))(arr)

compose(prop('result'), reduce((a, b) => evolve(
{
result: merge(__, objOf(arr[b], slice(b + 1, k[a.index + 1])(arr))),
}, a
), {result: {}, index: 0}))(k);
ram-bot
@ram-bot
May 23 2016 19:46
{}
Taylor Hurt
@thurt
May 23 2016 19:50
Denis Stoyanov
@xgrommx
May 23 2016 19:51
This message was deleted
ram-bot
@ram-bot
May 23 2016 19:51
{}
Denis Stoyanov
@xgrommx
May 23 2016 19:51
strange
hkrutzer
@hkrutzer
May 23 2016 21:29
yeah thanks @xgrommx :)