These are chat archives for ramda/ramda

1st
Jul 2016
Chet Harrison
@ChetHarrison
Jul 01 2016 15:32
k thanks @davidchambers
that would be a nice optimization. But I am not sure if I'm the guy to do it :smile:
Bravi
@Bravilogy
Jul 01 2016 16:38

guys I have the following array:

[
   [ 1, 2, 3, 4, 5],
   [ 6, 7, 8, 9, 10],
   [ 11, 12, 13, 14, 15]
]

and I want to have this:

[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ]

Brad Compton (he/him)
@Bradcomp
Jul 01 2016 16:39
@Bravilogy Can you use R.flatten?
Bravi
@Bravilogy
Jul 01 2016 16:40
yeah works, thank you!
one more question please. Let's say if I wanted to join each array and have a result something like this:
[ "12345", "678910", "1112131415" ]
is that possible to do?
actually, I'll struggle a bit here :) better that way
and if I can't figure out, then I'll come back
Brad Compton (he/him)
@Bradcomp
Jul 01 2016 16:45

is that possible to do?

Yes ;)

Chet Harrison
@ChetHarrison
Jul 01 2016 16:45
just map a flatten over the first array
Bravi
@Bravilogy
Jul 01 2016 16:52

yaay figure it out.

So basically, I was following the 'ramda demo' tutorial on youtube (https://www.youtube.com/watch?v=digajAH_5IU) where the guy creates a transposeSquare function and for some reason his version didn't work for me. So this works for me:

    var transposeSquare = R.pipe(
        R.map(R.split('')),
        R.transpose,       
        R.map(R.join(''))
    );
Bravi
@Bravilogy
Jul 01 2016 17:14
if anyone decides to follow that video, here's my final solution to that one function:
var transposeSquare = R.pipe(
        R.map(R.pipe(R.split(''), R.reject(R.test(/\s/)))),
        R.transpose,
        R.map(R.join(''))
);