Puppet Function: math::sum

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

Summary

Produces a sum of all the numbers

Overview

math::sum(Variant[Numeric, Array[Numeric], Tuple] $value)Numeric

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

Parameters:

  • value (Variant[Numeric, Array[Numeric], Tuple])

Returns:

  • (Numeric)


8
9
10
# File 'functions/sum.pp', line 8

function math::sum(Variant[Numeric, Array[Numeric], Tuple] *$value ) >> Numeric {
  $value.flatten.reduce | Numeric $acc, Numeric $v| { $acc + $v }
}