Enum.chunk / 2 (or Stream.chunk / 2 ) will break the list down to a sublist of x elements:
iex> [1,2,3,4,5,6,7,8,9,10] |> Enum.chunk(5) [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]
Then you can act on each list, for example:
iex> ["1","2","3","4","5","6","7","8","9","10"] |> Enum.chunk(5) |> Enum.each(fn x -> IO.puts x end) 12345 678910
source share