Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def zip(a, b) do
list = to_list(a)
throw do
{ zipped, rest } = Reducers.reduce(b, { [], list }, fn
entry, { acc, [h|t] } -> { [{entry, h}|acc], t }
entry, { acc, [] } -> throw { :enum_zip, acc }
end)
:lists.foldl(fn(x, acc) ->
[{ x, nil }|acc]
end, zipped, rest) |> :lists.reverse
catch
{ :enum_zip, rest } ->
:lists.reverse(rest)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.