Puppet Function: math::exp

Defined in:
functions/exp.pp
Function type:
Puppet Language

Summary

Performs exponential (power) calculation on given number

Overview

math::exp(Numeric $x, Integer[0,62] $y)Numeric

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

Parameters:

  • x (Numeric)
  • y (Integer[0,62])

Returns:

  • (Numeric)


8
9
10
11
12
# File 'functions/exp.pp', line 8

function math::exp(Numeric $x, Integer[0,62] $y) >> Numeric {
  if $y == 0 { return $x }
  $loops = range(1,$y - 1)
  $loops.reduce($x) |$acc, $_value | { $acc * $x  }
}