Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Simplified representation of source data
- data = ["A", "B", "B", "A", "C", "A", "D"]
- Stream.transform(data, "", fn(line, acc) ->
- if line == "A" do
- if acc == "", do: {[], line}, else: {[acc], line}
- else
- {[], acc <> line}
- end
- end) |> Enum.to_list
- # Desired: ["ABB", "AC", "AD"]
- # Result: ["ABB", "AC"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement