Skip to content

Instantly share code, notes, and snippets.

@blackode
Last active February 19, 2017 19:59
Show Gist options
  • Save blackode/0280822fb6857c5b50c9987f02b3ac6e to your computer and use it in GitHub Desktop.
Save blackode/0280822fb6857c5b50c9987f02b3ac6e to your computer and use it in GitHub Desktop.
defmodule WhileLoop do
defmacro while(condition_expression, do: do_block) do
quote do
for _ <- Stream.cycle([:fine]) do
if unquote(condition_expression) do
unquote(do_block)
else
# break out of loop
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment