Skip to content

Instantly share code, notes, and snippets.

@sergeant-wizard
Created October 30, 2015 05:03
Show Gist options
  • Save sergeant-wizard/2d446b69ae8d635604be to your computer and use it in GitHub Desktop.
Save sergeant-wizard/2d446b69ae8d635604be to your computer and use it in GitHub Desktop.
nested loop in elixir
defmodule Loop do
def each([head|tail], fun) do
[fun.(head)|each(tail, fun)]
end
def each([], _) do
[]
end
end
Loop.each [1, 2], fn element ->
Loop.each [3, 4], fn element_ ->
IO.inspect {element, element_}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment