Corner.Fn (corner v0.1.3)

This module define macro fn!/2.

fn!/2 can be use to define recursivable anonymous function.

Link to this section Summary

Functions

Define recursivalbe anonymous function.

Link to this section Functions

Link to this macro

fn!(name, do_block)

(macro)

Define recursivalbe anonymous function.

name is the name of the anonymous function.

block is the caluses of the function, same as in fn.

This macro will inject variable name to caller's context.

example

Example

iex> import Corner.Fn
iex> fn! sum_to do
...>   0 -> 0
...>  n when is_integer(n) and n > 0  -> n + sum_to.(n - 1)
...> end
iex> sum_to.(100)
5050
iex> :sum_to in (binding() |> Keyword.keys())
true