Currently, Enum.chunk_every starts chunking at the start of the list. So it's impossible to generate chunks with "leftovers" on both sides without extra tinkering. I propose adding an offset argument (the index from which the first chunk would start) to the Enum.chunk_every function.
so [1,2,3,4,5] with count 3 step 2 and offset of -2 would return [1], [1,2], [1,2,3], [2,3,4], [3,4,5], [4,5], [5] Elements in the leftover option would be to the left of the initial chunks less than count. It'd also be neat if you could have different leftover options for the left-hand and right-hand leftovers. Some of my potato code where this feature could be used - it's one way of implementing Conway's Game of Life logic. See setup_arr. Enum.chunk_every(row, 3, 1, -1, [0]) in place of the first setup_arr https://github.com/konstantin-aa/gamesoflife/blob/main/main.exs -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/74210a62-7287-4a33-ac25-e9d83b1067acn%40googlegroups.com.