Codegolf challenge - mapping values in a multidimensional array
[
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]
]
This 2D array is sick of being so false, and wants to find the truth about life, once and for all. Your task is to write a map function to act as a highway to all the values in this array.
An example implementation of this super function would be if the above array is defined as arr
below:
arr.multimap(x => {
return 1;
}
Which would result in the array being:
[
[1, 1, 1],
[1, 1, 1],
[1, 1, 1]
]
This is a 2D number example, yours has to work in any dimension, and not be dimensionally-bias.
The rules
- Must work in any type of dimensional array (1D, 2D, 3D, etc..)
- Least bytes, wins!
- Must only have one callback function which accounts for any level of dimensional interaction
- Meta-languages get fewer points
- Can simply be a function which applies the logic to an array given
- Can be any arbitrary initial value, as long as you can replace it on-command