# Is there a way to have a nested expression loop

I’m trying to unwrap a vector of vectors of vectors into one vector and my first thought is to

``````[k for i in vecs, j in i, k in j]
or
[k for k in j, j in i, i in vecs]
``````
``````ERROR: UndefVarError: i/j not defined
``````

Do I need to use a full for loop or am I missing something?

Perhaps you mean something like:

``````[ k for i in vecs for j in 1:i for k in 1:j ]
``````

Your `i` in `j in i` is an element and not iterable. Same for `j` in `k in j`.

ok, I see vector of vector… ok, it should work, but with `for` and not `,` separated.

``````julia> a= [ [1,2,3], [2,3,4,5,6] ]
2-element Vector{Vector{Int64}}:
[1, 2, 3]
[2, 3, 4, 5, 6]

julia> [j for i in a for j in i ]
8-element Vector{Int64}:
1
2
3
2
3
4
5
6
``````

Iterators.flatten(a) isn’t going deep, so it’s a bit tricky with that …

Best to check here: https://discourse.julialang.org/t/how-do-you-unfold-a-nested-julia-array

yes! there it is! thank you. easy enough to iterate with flatten.