Created
July 4, 2017 02:28
-
-
Save drakeirving/0456b9437b4f8a995e8f714b1b131800 to your computer and use it in GitHub Desktop.
nd-array set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ndset(a, inds, b){ | |
if(length(inds) == 0){ return b; } | |
let temp = a; | |
temp[inds[0]] = ndset(a[inds[0]], inds[1..length(inds)], b); | |
return temp; | |
} | |
// let a = [[[0,1],[2,3]],[[4,5],[6,7]]]; | |
// let b = ndset(a, [0,1,1], 8); | |
// b #=> [[[0,1],[2,8]],[[4,5],[6,7]]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment