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
Curried multiply/2
Multiplication
Multiply a number times -1.
Curried subtract/2
Subtract the second argument from the first.
Link to this section Functions
Specs
Curried Add/2
Example
iex> addOne = Fxnk.Math.add(1)
iex> addOne.(2)
3
Specs
Add two numbers together
Example
iex> Fxnk.Math.add(1, 2)
3
Specs
Averages a list of numbers, returns a float.
Examples
iex> Fxnk.Math.avg([1,4,3,2,5])
3.0
Specs
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
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
Decrement a number
Example
iex> Fxnk.Math.dec(1)
0
Specs
Curried divide
Examples
iex> recip = Fxnk.Math.divide(1)
iex> recip.(4)
0.25
Specs
Division.
divide(a, b) == a / b
Examples
iex(1)> Fxnk.Math.divide(1, 4) 0.25
Specs
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
Curried multiply/2
Examples
iex> timesTen = Fxnk.Math.multiply(10)
iex> timesTen.(10)
100
Specs
Multiplication
multiply(a, b) == a * b
Examples
iex> Fxnk.Math.multiply(10, 10)
100
Specs
Multiply a number times -1.
Examples
iex> Fxnk.Math.negate(100) -100 iex> Fxnk.Math.negate(-100) 100
Specs
Curried subtract/2
Examples
iex> minusOne = Fxnk.Math.subtract(1)
iex> minusOne.(5)
4
Specs
Subtract the second argument from the first.
Examples
iex> Fxnk.Math.subtract(5, 1)
4