Version information
This version is compatible with:
- Puppet Enterprise 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2016.4.x
- Puppet >= 4.10.0 < 7.0.0
- , , , , , , , , , ,
Start using this module
Add this module to your Puppetfile:
mod 'nwops-math', '0.2.0'
Learn more about managing modules with a PuppetfileDocumentation
Puppet math
A puppet module with a few math functions. Purely written in native puppet code.
This library might be useful in your code, but was created mostly for nerd sniping.
Adding new functions
Want to add a new function? Create a native puppet function and submit a PR.
All ruby based submissions are subject to rejection.
Reference
Table of Contents
Functions
math::constants
Internal use onlymath::cube
: Cubes a numbermath::exp
: Performs exponential (power) calculation on given numbermath::fibonacci
: Calculate the fibonacci sequence for the given numbermath::fibonacci::binet
: Calculate the fibonacci sequence for the given number using binet methodmath::fibonacci::table
: Calculate the fibonacci sequence for the given number using table methodmath::round
: rounds to the nearset decimalmath::sqrt
: returns the square root of the numeric value $x.math::square
: Squares a numbermath::sum
: Produces a sum of all the numbers
Functions
math::constants
Type: Puppet Language
The math::constants function.
math::constants(String $name)
The math::constants function.
Returns: Any
name
Data type: String
math::cube
Type: Puppet Language
Cubes a number
- Note puppet has a integer size limit so some values may not work and return a Puppet::ParseError
Examples
2
math::cube(2) => 8
3
math::cube(3) => 27
math::cube(Numeric $value)
The math::cube function.
Returns: Numeric
Examples
2
math::cube(2) => 8
3
math::cube(3) => 27
value
Data type: Numeric
math::exp
Type: Puppet Language
Produces a Integer that is an exponential power calculation on the provided value and power.
- Note puppet has a integer size limit so some values may not work and return a Puppet::ParseError
Examples
2^3
math::exp(2,3) => 8
2^8
math::exp(2,8) => 256
math::exp(Numeric $x, Integer[0,62] $y)
Produces a Integer that is an exponential power calculation on the provided value and power.
Returns: Numeric
Examples
2^3
math::exp(2,3) => 8
2^8
math::exp(2,8) => 256
x
Data type: Numeric
y
Data type: Integer[0,62]
math::fibonacci
Type: Puppet Language
Calculate the fibonacci sequence for the given number
- Note The input value maxes out at 27 because it takes too long to calclulate
math::fibonacci(Numeric $n, Enum[table,binet] $method = 'table')
The math::fibonacci function.
Returns: Integer
n
Data type: Numeric
method
Data type: Enum[table,binet]
math::fibonacci::binet
Type: Puppet Language
Calculate the fibonacci sequence for the given number using binet method
- Note The input value maxes out at 27 because it takes too long to calclulate
math::fibonacci::binet(Numeric $n)
The math::fibonacci::binet function.
Returns: Numeric
n
Data type: Numeric
math::fibonacci::table
Type: Puppet Language
Calculate the fibonacci sequence for the given number using table method
- Note The input value maxes out at 27 because it takes too long to calclulate
math::fibonacci::table(Numeric $n)
The math::fibonacci::table function.
Returns: Numeric
n
Data type: Numeric
math::round
Type: Puppet Language
rounds to the nearset decimal
math::round(Numeric $x)
The math::round function.
Returns: Numeric
x
Data type: Numeric
math::sqrt
Type: Puppet Language
returns the square root of the numeric value $x.
- Note This implementation uses Newton's method.
Examples
Square root of 9
math::sqrt(9) => 3
math::sqrt(Numeric $x)
The math::sqrt function.
Returns: Numeric
Examples
Square root of 9
math::sqrt(9) => 3
x
Data type: Numeric
math::square
Type: Puppet Language
Squares a number
- Note puppet has a integer size limit so some values may not work and return a Puppet::ParseError
Examples
2
math::square(2) => 4
3
math::square(3) => 9
math::square(Numeric $value)
The math::square function.
Returns: Numeric
Examples
2
math::square(2) => 4
3
math::square(3) => 9
value
Data type: Numeric
math::sum
Type: Puppet Language
Produces a Integer that is sum of all the numbers provided. Can take arrays or multiple values.
- Note puppet has a integer size limit so some values may not work and return a Puppet::ParseError
Examples
with array
math::sum([2,2,2]) => 6
without array
math::sum(2,2,2) => 6
math::sum(Variant[Numeric, Array[Numeric], Tuple] $value)
Produces a Integer that is sum of all the numbers provided. Can take arrays or multiple values.
Returns: Numeric
Examples
with array
math::sum([2,2,2]) => 6
without array
math::sum(2,2,2) => 6
value
Data type: Variant[Numeric, Array[Numeric], Tuple]
Dependencies
- puppetlabs/stdlib (>= 4.13.1 < 7.0.0)