I have a simple Go for loop and i want to learn how to do this with Recursion in Elixir. I don't really know how the recursion loop works at this time but i am working on that part! I also don't know if this is even the right way to do recursive functions.
package main
import "fmt"
func main() {
for i := 0; i < 10000000; i++ {
fmt.Println(i)
}
}
defmodule Looping do
def loops(i, e) when e <= 0 do
IO.puts i + e
end
def loops(i, e) do
IO.puts i + e
loops(i, e + 1)
end
end
Looping.loops(1, 1)
Produces 1 + 1 + 1 on going in Elixir.
Martin over at the beginners slack channel suggested the following.
1..1_000_000 |> Enum.each(&IO.puts/1)