Add Elixir examples for recursion

This commit is contained in:
Evgeny Garlukovich
2018-02-04 19:02:52 +03:00
committed by Aditya Bhargava
parent fa35ae875d
commit 687d3fece6
3 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
defmodule Countdown do
defguardp non_positive?(x) when x <= 0
def from(i) when non_positive?(i), do: nil
def from(i) do
IO.puts(i)
from(i - 1)
end
end
Countdown.from(5)