These are chat archives for ramda/ramda

17th
Apr 2017
Rafi
@Rafi993
Apr 17 2017 12:44
Hi, I have an array ```
sorry for the typo

Hi, I have an array

[[1,2,3],[4,5,6],[7,8,9]]

I am trying get

[[1,4,7],[2,5,8],[3,6,9]]
Rafi
@Rafi993
Apr 17 2017 12:49
i'm trying to do it in point free form
Denis Stoyanov
@xgrommx
Apr 17 2017 12:50
@Rafi993 transpose
@ram-bot transpose([[1,2,3],[4,5,6],[7,8,9]])
ram-bot
@ram-bot
Apr 17 2017 12:50
[ [ 1, 4, 7 ], [ 2, 5, 8 ], [ 3, 6, 9 ] ]
Rafi
@Rafi993
Apr 17 2017 12:51
thanks @ram-bot
Denis Stoyanov
@xgrommx
Apr 17 2017 12:51
:smile:
Martin Broder
@mrtnbroder
Apr 17 2017 18:20
Hey there!
does someone have an idea how to Split an Array of values like this '[1,2,3,4,5,6,7,8,9]' into chunks that have a min and max size.
Robert Mennell
@skatcat31
Apr 17 2017 18:22
Example output?
Martin Broder
@mrtnbroder
Apr 17 2017 18:24
Output: [[1,2,3],[4,5,6,7],[8,9]]
where min is 3 and max is 4
In this example
BUT
max could be 5 as well and then, it should count backwards
better example:
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
splitMinMax(3,5)
output:
[[1,2,3],[4,5,6,7],[8,9,10,11,12],[13,14,15,16]]
got it?
Robert Mennell
@skatcat31
Apr 17 2017 18:27
so if we go by lengths:
fn(min, max)(array) -> [
length = min,
length = min + 1,
length = min + 2,
length = min + ...,
length = max,
length = max - 1,
length = max -2,
length = max - 3,
length = max - ...,
length = min,
length = min + ...,
repeat]
Martin Broder
@mrtnbroder
Apr 17 2017 18:33
Well simply put: size Starts at min, when chunk equals size, add 1, repeat until it reaches Max, then do the reverse process and count downwards until we reach min
Robert Mennell
@skatcat31
Apr 17 2017 18:33
cyclical?
Martin Broder
@mrtnbroder
Apr 17 2017 18:33
Yer
im
Denis Stoyanov
@xgrommx
Apr 17 2017 18:36
why not slice?
@ram-bot sequence(always, [slice(0, 3), slice(3, 7), slice(7, 12), slice(12, 16)])([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])
ram-bot
@ram-bot
Apr 17 2017 18:40
[ [ 1, 2, 3 ],
  [ 4, 5, 6, 7 ],
  [ 8, 9, 10, 11, 12 ],
  [ 13, 14, 15, 16 ] ]
Martin Broder
@mrtnbroder
Apr 17 2017 18:41
Well the sequence is dynamic
Robert Mennell
@skatcat31
Apr 17 2017 18:41
I always forget about sequence...
Martin Broder
@mrtnbroder
Apr 17 2017 18:42
where is my min/max ?
Denis Stoyanov
@xgrommx
Apr 17 2017 18:42
use addIndex(traverse(always))((x, i) => ...)(arr)
Martin Broder
@mrtnbroder
Apr 17 2017 18:42
:)
Robert Mennell
@skatcat31
Apr 17 2017 18:47
@xgrommx isn't that just reduce?
Martin Broder
@mrtnbroder
Apr 17 2017 18:50
yeah looks a lot like reduce
lemme try to get a working version