Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Enum.split_with([5, 4, 3, 2, 1, 0], fn(x) -> rem(x, 2) == 0 end)
- {[4, 2, 0], [5, 3, 1]}
- Enum.reduce([5, 4, 3, 2, 1, 0], {[], []}, fn(x, {xs, ys}) ->
- if rem(x, 2) == 0, do: {[x | xs], ys}, else: {xs, [x | ys]} end)
- {[4, 2, 0], [5, 3, 1]}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement