Stepping into Elixir Ranges
Elixir 1.12 introduced a new syntax suggar into Ranges first..last//step.
iex(1)> 1..10 |> Enum.to_list()
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
iex(2)> 1..10//2 |> Enum.to_list()
[1, 3, 5, 7, 9]
iex(3)> 1..10//3 |> Enum.to_list()
[1, 4, 7, 10]
The same could already be done with the amazing Stream module by using the take_every/2.
Tweet