Mandrake v0.0.2 Mandrake.Math
Mandrake mathematical functions.
Summary
Functions
Calculates the absolute value of each number in a list
Returns a function that adds a number to the first
Adds two numbers
Decrease a number by 1
Returns a function that divides a number to the first
Divides two numbers
Increase a number by 1
Returns max value in a list
Calculates the mean of a list of numbers
Calculates the median of a list of numbers
Returns min value in a list
Returns modulus of two numbers
Returns a function that multiplies a number to the first
Multiplies two numbers
Negate a number
Calculates the product of a list of numbers
Returns a function that subtracts a number to the first
Subtracts two numbers
Calculates the sum of a list of numbers
Functions
Calculates the absolute value of each number in a list.
Examples
iex> Mandrake.Math.abs([-1, 2, -3, -4, -5])
[1, 2, 3, 4, 5]
Returns a function that adds a number to the first.
Examples
iex> add2 = Mandrake.Math.add(2)
...> add2.(5)
7
Returns a function that divides a number to the first.
Examples
iex> divide2 = Mandrake.Math.divide(2)
...> divide2.(5)
0.4
Divides two numbers.
Examples
iex> Mandrake.Math.divide(5, 2)
2.5
Calculates the mean of a list of numbers.
Examples
iex> Mandrake.Math.mean([1, 2, 3, 4, 5])
3.0
Calculates the median of a list of numbers.
Examples
iex> Mandrake.Math.median([7, 2, 10, 9, 6])
7
iex> Mandrake.Math.median([7, 2, 10, 9, 6, 8])
7.5
Returns modulus of two numbers.
Examples
iex> Mandrake.Math.modulo(20, 5)
0
Returns a function that multiplies a number to the first.
Examples
iex> multiply2 = Mandrake.Math.multiply(2)
...> multiply2.(5)
10
Multiplies two numbers.
Examples
iex> Mandrake.Math.multiply(5, 2)
10
Calculates the product of a list of numbers.
Examples
iex> Mandrake.Math.product([1, 2, 3, 4, 5])
120
Returns a function that subtracts a number to the first.
Examples
iex> subtract2 = Mandrake.Math.subtract(2)
...> subtract2.(5)
-3
Subtracts two numbers.
Examples
iex> Mandrake.Math.subtract(5, 2)
3