Advertisement
Guest User

Untitled

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