Created
October 30, 2015 05:03
-
-
Save sergeant-wizard/2d446b69ae8d635604be to your computer and use it in GitHub Desktop.
nested loop in elixir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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