How to use the transpose function from ramda

Find comprehensive JavaScript ramda.transpose code examples handpicked from public code repositorys.

21
22
23
24
25
26
27
28
29
30
      return acc
    },
    {},
  ),
),
columns: R.transpose(board).map(
  (row, rowIndex) => row.reduce(
    (acc, square, columnIndex) => {
      if (square !== '.') {
        return {
fork icon1
star icon0
watch icon0

9
10
11
12
13
14
15
16
17
18
19
20


function parse(lines) {
    const sections = R.splitWhen(R.isEmpty, lines);


    const stackElements = sections[0].map(R.splitEvery(4));
    const stackElementsTransposed = R.transpose(stackElements)
    
    const stacks = stackElementsTransposed
        .map(R.dropLast(1))
        .map(R.dropWhile(x => R.trim(x).length < 1))
fork icon0
star icon0
watch icon0

+ 3 other calls in file

4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
* @param {Array} list A 2D list
* @return {Array} A 2D list
* @example
*
*      R.transpose([[1, 'a'], [2, 'b'], [3, 'c']]) //=> [[1, 2, 3], ['a', 'b', 'c']]
*      R.transpose([[1, 2, 3], ['a', 'b', 'c']]) //=> [[1, 'a'], [2, 'b'], [3, 'c']]
*
* If some of the rows are shorter than the following rows, their elements are skipped:
*
*      R.transpose([[10, 11], [20], [], [30, 31, 32]]) //=> [[10, 20, 30], [11, 31], [32]]
fork icon0
star icon0
watch icon0

+ 53 other calls in file

188
189
190
191
192
193
194
195
196

const dxs = [1, 0, -1, 0];
const dys = [0, 1, 0, -1];

const rowLengths = map.map(r => r.filter(x => x !== ' ').length);
const columnLengths = R.transpose(map).map(r => r.filter(x => x !== ' ').length);

U.log('row lengths', rowLengths);
U.log('column lengths', columnLengths);
fork icon0
star icon0
watch icon0

13853
13854
13855
13856
13857
13858
13859
13860
13861
*      R.transpose([[1, 2, 3], ['a', 'b', 'c']]) //=> [[1, 'a'], [2, 'b'], [3, 'c']]
*
*      // If some of the rows are shorter than the following rows, their elements are skipped:
*      R.transpose([[10, 11], [20], [], [30, 31, 32]]) //=> [[10, 20, 30], [11, 31], [32]]
* @symb R.transpose([[a], [b], [c]]) = [a, b, c]
* @symb R.transpose([[a, b], [c, d]]) = [[a, c], [b, d]]
* @symb R.transpose([[a, b], [c]]) = [[a, c], [b]]
*/

fork icon0
star icon0
watch icon2

+ 23 other calls in file

20
21
22
23
24
25
26
27
28
29
30
31
const markNumber = (n) => R.map(
    R.map(R.ifElse(R.equals(n), R.always(-1), R.identity)));


const isWinner = (b) => R.any(
    R.any(R.all(R.gt(0))),
    [b, R.transpose(b)]);


const score = R.compose(
    R.sum,
    R.filter(R.lt(0)),
fork icon0
star icon0
watch icon0

Other functions in ramda

Sorted by popularity

function icon

ramda.clone is the most popular function in ramda (30311 examples)