Mandrake v0.0.1 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

Decrease a number by 1

Returns a function that divides a number to the first

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

Calculates the sum of a list of numbers

Functions

abs(list)

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]
add(number)

Returns a function that adds a number to the first.

Examples

iex>  add2 = Mandrake.Math.add(2)
...>  add2.(5)
7
add(first_number, second_number)

Adds two numbers.

Examples

iex>  Mandrake.Math.add(5, 2)
7
dec(number)

Decrease a number by 1.

Examples

iex>  Mandrake.Math.dec(7)
6
divide(number)

Returns a function that divides a number to the first.

Examples

iex>  divide2 = Mandrake.Math.divide(2)
...>  divide2.(5)
0.4
divide(first_number, second_number)

Divides two numbers.

Examples

iex>  Mandrake.Math.divide(5, 2)
2.5
inc(number)

Increase a number by 1.

Examples

iex>  Mandrake.Math.inc(7)
8
max(list)

Returns max value in a list.

Examples

iex>  Mandrake.Math.max([1, 243, 3, 4, 5])
243
mean(list)

Calculates the mean of a list of numbers.

Examples

iex> Mandrake.Math.mean([1, 2, 3, 4, 5])
3.0
median(list)

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
min(list)

Returns min value in a list.

Examples

iex>  Mandrake.Math.min([1, 243, 3, 4, 5])
1
modulo(first_number, second_number)

Returns modulus of two numbers.

Examples

iex>  Mandrake.Math.modulo(20, 5)
0
multiply(number)

Returns a function that multiplies a number to the first.

Examples

iex>  multiply2 = Mandrake.Math.multiply(2)
...>  multiply2.(5)
10
multiply(first_number, second_number)

Multiplies two numbers.

Examples

iex>  Mandrake.Math.multiply(5, 2)
10
negate(number)

Negate a number.

Examples

iex>  Mandrake.Math.negate(7)
-7
product(list)

Calculates the product of a list of numbers.

Examples

iex> Mandrake.Math.product([1, 2, 3, 4, 5])
120
subtract(number)

Returns a function that subtracts a number to the first.

Examples

iex>  subtract2 = Mandrake.Math.subtract(2)
...>  subtract2.(5)
-3
subtract(first_number, second_number)

Subtracts two numbers.

Examples

iex>  Mandrake.Math.subtract(5, 2)
3
sum(list)

Calculates the sum of a list of numbers.

Examples

iex> Mandrake.Math.sum([1, 2, 3, 4, 5])
15