Your X are ordered.
In example 1, chunk_by sees x=1, x=1 then x=2, so it emits a chunk for both 1, then starts a new chunk and finally x=2 makes it to the same chunk.
In the second example, you have, 3, 4, 3, 4, so that is 4 chunks because at each number, a new chunk is started.
iex(1)> Enum.chunk_by([1,1,2,2], & &1)
[[1, 1], [2, 2]]
iex(2)> Enum.chunk_by([1,2,1,2], & &1)
[[1], [2], [1], [2]]






















