FunFunc v0.2.0 FunFunc.Num

Functions for Number.

Link to this section Summary

Functions

Returns division and remainder

Checks the value is a negative number

Checks the value is not zero

Checks the value is a positive number

Predecessor function

Successor function

Iterates function for x times

Checks the value is zero

Link to this section Functions

Link to this function divmod(x, y)
divmod(integer(), integer()) :: {integer(), integer()}

Returns division and remainder.

Examples

iex> FunFunc.Num.divmod(5, 2)
{2, 1}
iex> FunFunc.Num.divmod(5, 0)
** (ArithmeticError) bad argument in arithmetic expression
Link to this function negative?(x)
negative?(number()) :: boolean()

Checks the value is a negative number.

Examples

iex> FunFunc.Num.negative?(1)
false
iex> FunFunc.Num.negative?(0)
false
iex> FunFunc.Num.negative?(-1)
true
Link to this function non_zero?(x)
non_zero?(number()) :: boolean()

Checks the value is not zero.

Examples

iex> FunFunc.Num.non_zero?(0)
false
iex> FunFunc.Num.non_zero?(1)
true
Link to this function positive?(x)
positive?(number()) :: boolean()

Checks the value is a positive number.

Examples

iex> FunFunc.Num.positive?(1)
true
iex> FunFunc.Num.positive?(0)
false
iex> FunFunc.Num.positive?(-1)
false
Link to this function pred(x)
pred(integer()) :: integer()

Predecessor function.

Examples

iex> FunFunc.Num.pred(43)
42
Link to this function succ(x)
succ(integer()) :: integer()

Successor function.

Examples

iex> FunFunc.Num.succ(41)
42
Link to this function times(x, f)
times(integer(), (... -> any())) :: atom()

Iterates function for x times.

Sample

FunFunc.Num.times(3, &IO.puts/1)
#=> 1
#=> 2
#=> 3
:ok
Link to this function zero?(x)
zero?(number()) :: boolean()

Checks the value is zero.

Examples

iex> FunFunc.Num.zero?(0)
true
iex> FunFunc.Num.zero?(1)
false