Slicing vector into matrix

How to do this ? If there is a function?

I have a large vector with repeating numbers after some interval. I want to slice it just like how showed in second output.

Thank you :slight_smile:


julia> a = [1, 1, 1, 1, 2, 2, 2, 2]
12-element Vector{Int64}:
 1
 1
 1
 1
 2
 2
 2
 2
4×2 Matrix{Int64}:
 1  2
 1  2
 1  2
 1  2

https://docs.julialang.org/en/v1/base/arrays/#Base.reshape

4 Likes