Fxnk v0.1.1 Fxnk.Math View Source

Fxnk.Math are functions dealing with math.

Link to this section Summary

Functions

Curried Add/2

Add two numbers together

Averages a list of numbers, returns a float.

Curried clamp/3. Restrict a number to be between a range of numbers.

Restrict a number to be between a range of numbers.

Decrement a number

Curried divide

Division.

Increment a number

Find the maximum of a list.

Find the minimum of a list

Multiplication

Multiply a number times -1.

Subtract the second argument from the first.

Link to this section Functions

Specs

add(number()) :: function()

Curried Add/2

Example

iex> addOne = Fxnk.Math.add(1)
iex> addOne.(2)
3

Specs

add(number(), number()) :: number()

Add two numbers together

Example

iex> Fxnk.Math.add(1, 2)
3

Specs

avg([number(), ...]) :: float()

Averages a list of numbers, returns a float.

Examples

iex> Fxnk.Math.avg([1,4,3,2,5])
3.0

Specs

clamp(integer(), integer()) :: (... -> any())

Curried clamp/3. Restrict a number to be between a range of numbers.

Example

iex> between1And10 = Fxnk.Math.clamp(1, 10)
iex> between1And10.(-5)
1
iex> between1And10.(15)
10

Specs

clamp(integer(), integer(), integer()) :: integer()

Restrict a number to be between a range of numbers.

Example

iex> Fxnk.Math.clamp(13, 15, 20)
15
iex> Fxnk.Math.clamp(21, 15, 20)
20
iex> Fxnk.Math.clamp(17, 15, 20)
17

Specs

dec(integer()) :: integer()

Decrement a number

Example

iex> Fxnk.Math.dec(1)
0

Specs

divide(number()) :: function()

Curried divide

Examples

iex> recip = Fxnk.Math.divide(1)
iex> recip.(4)
0.25

Specs

divide(number(), number()) :: float()

Division.

divide(a, b) == a / b

Examples

iex(1)> Fxnk.Math.divide(1, 4) 0.25

Specs

inc(integer()) :: integer()

Increment a number

Example

iex> Fxnk.Math.inc(1)
2

Specs

max([...]) :: any()

Find the maximum of a list.

Example

iex> Fxnk.Math.max([1337, 42, 23])
1337

Specs

min([...]) :: any()

Find the minimum of a list

Example

iex> Fxnk.Math.min([1337, 42, 23])
23

Specs

multiply(number()) :: function()

Curried multiply/2

Examples

iex> timesTen = Fxnk.Math.multiply(10)
iex> timesTen.(10)
100

Specs

multiply(number(), number()) :: number()

Multiplication

multiply(a, b) == a * b

Examples

iex> Fxnk.Math.multiply(10, 10)
100

Specs

negate(number()) :: number()

Multiply a number times -1.

Examples

iex> Fxnk.Math.negate(100) -100 iex> Fxnk.Math.negate(-100) 100

Specs

subtract(number()) :: function()

Curried subtract/2

Examples

iex> minusOne = Fxnk.Math.subtract(1)
iex> minusOne.(5)
4

Specs

subtract(number(), number()) :: number()

Subtract the second argument from the first.

Examples

iex> Fxnk.Math.subtract(5, 1)
4