I’d like to apply a function to each element of a nested array. To illustrate
julia> arr = [[1,2,3],[4,5,6]]
2-element Array{Array{Int64,1},1}:
[1, 2, 3]
[4, 5, 6]
julia> map(arr) do ls
map(ls) do x
x+1
end
end
2-element Array{Array{Int64,1},1}:
[2, 3, 4]
[5, 6, 7]
Now say arr is nested 3 levels, then things start to get quite unwieldy. I thought of doing something like map(k for i in arr for j in i for k in j)
but that flattens the list. Unfortunately, the syntax map(k for i in arr, j in i, k in j)
doesn’t work like it does for nested arrays of fixed size. Any suggestion on how to implement an operation like this in a nicer way? Loops solve it somewhat nicely, but you are forced to iteratively push into some array.