Skip to content

Instantly share code, notes, and snippets.

View IslandUsurper's full-sized avatar

Lyle Mantooth IslandUsurper

  • @vpsinc
  • Pewee Valley, KY
View GitHub Profile
@pmarreck
pmarreck / for_all_the_things.exs
Created October 9, 2017 17:13
Examples of various uses of the "for" syntax in Elixir
# A list generator:
iex> for n <- [1, 2, 3, 4], do: n * 2
[2, 4, 6, 8]
# A comprehension with two generators
iex> for x <- [1, 2], y <- [2, 3], do: x * y
[2, 3, 4, 6]
# A comprehension with a generator and a filter
iex> for n <- [1, 2, 3, 4, 5, 6], rem(n, 2) == 0, do: n