Recurse
Explicit recursion inside functions with a recursive block.
Documentation
Installation
The package can be installed by adding recurse to your list of dependencies in mix.exs:
def deps do
[
{:recurse, "~> 0.1.0"}
]
endUsage
Without Recurse, a tail-recursive definition of reverse could be written like so:
def reverse(list), do: do_reverse(list, [])
defp do_reverse([], acc), do: acc
defp do_reverse([head | tail], acc) do
do_reverse(tail, [head | acc])
endWith Recurse you could do it like this:
def reverse(list) do
recurs on list, [] do
[], acc -> acc
[head | tail], acc -> recurs tail, [head | acc]
end
endLicense
Recurse is released under the GPL-3.0 license - see the LICENSE file.