An ArrayPartition should be a good data structure for this.
https://github.com/SciML/RecursiveArrayTools.jl#arraypartition