Skip to content

Instantly share code, notes, and snippets.

@blackode
Last active February 19, 2017 20:57
Show Gist options
  • Select an option

  • Save blackode/cb14d767765197d5d1b0eeb9f19653c6 to your computer and use it in GitHub Desktop.

Select an option

Save blackode/cb14d767765197d5d1b0eeb9f19653c6 to your computer and use it in GitHub Desktop.
Defiinig the macros and Testing
defmodule WhileLoop do
defmacro while(condition_expression, do: do_block) do
quote do
try do
for _ <- Stream.cycle([:fine]) do
if(unquote(condition_expression)) do
unquote do_block
else
WhileLoop.break
end
end
catch
:break -> :ok
end
end
end
def break, do: throw :break
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment