elixir enum chunk_by

The chunk_by/2 function in Elixir's Enum module is used to split a list into sublists based on a given condition. It takes two arguments: the list to be chunked and a function that determines the condition for chunking.

Here's an example of how to use chunk_by/2:

list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Enum.chunk_by(list, fn x -> rem(x, 2) == 0 end)

In this example, the list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] is chunked into sublists based on the condition rem(x, 2) == 0, which checks if the element is even. The result will be [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]], where each element is in its own sublist.

Please let me know if you need further assistance!