Background
I have an array of arrays that represents a grid with the following format:
const grid = [
[null, null, null, null, null, null, null],
[null, null, null, null, null, null, null],
[null, "®" , null, null, null, null, "®" ],
["©" , "©" , null, null, "©" , "®" , "®" ],
["®" , "®" , "®" , "©" , "®" , "©" , "©" ],
["®" , "©" , "©" , "®" , "©" , "®" , "©" ],
];
Objective
My objective is to transform that array into the following:
const grid = [
{ row: 0, column: 1, value: null},
{ row: 0, column: 2, value: null},
{ row: 0, column: 3, value: null},
//... some rows after ...
{ row: 3, column: 0, value: "©"},
// etc...
];
Research
My first idea was to use two nested R.mapand the R.chain it. However I have a major problem: The ramda functions do not take indexes as parameters ( unlike the counter implementations in JavaScript ).
So I believe that doing this exercise using ramda, is not possible.
Question
Is there a way to do this exercise using only ramda functions ( no for loops ) ?
zipWithIndexin Scala.