Movatterモバイル変換


[0]ホーム

URL:


CFEngine documentation homepage

sum

Suggest changes
Table of contents

Prototype:sum(list)

Return type:real

Description: Return the sum of the reals inlist.

This function can accept many types of data parameters.

This function might be used for simple ring computation. Of course, you couldeasily combinesum withreadstringarray orreadreallist etc., to collectsummary information from a source external to CFEngine.

Arguments:

  • list:string - CFEngine variable identifier or inline JSON - in the range:.*

Example:

code
bodycommoncontrol{bundlesequence=>{"test"};}bundleagenttest{vars:"adds_to_six"ilist=>{"1","2","3"};"six"real=>sum("adds_to_six");"adds_to_zero"rlist=>{"1.0","2","-3e0"};"zero"real=>sum("adds_to_zero");reports:"six is$(six), zero is$(zero)";}

Output:

code
R: six is 6.000000, zero is 0.000000

Because$(six) and$(zero) are both real numbers, the report that isgenerated will be:

code
six is 6.000000, zero is 0.000000

Notes:

History: Was introduced in version 3.1.0b1,Nova 2.0.0b1 (2010). Thecollecting function behavior was added in 3.9.

See also:product(),about collecting functions, anddata documentation.

Still need help?

Chat Ask a question on Github Mailing list
Version 
master3.24 (LTS)3.21 (LTS)view all versions

[8]ページ先頭

©2009-2025 Movatter.jp