elixir enum chunk_by
Enum.chunk_by(["one", "two", "three", "four", "five"], fn(x) -> String.length(x) end) [["one", "two"], ["three"], ["four", "five"]] Enum.chunk_by(["one", "two", "three", "four", "five", "six"], fn(x) -> String.length(x) end) [["one", "two"], ["three"], ["four", "five"], ["six"]]
Source: elixirschool.com