Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This function is designed to return the sum of a list of values or the sum of a range in a list of values.

sum(List) → number

This function designed to calculate the sum of a list of numeric values or elements.

sum(List of list, start index, end index) → number

This function designed to calculate the sum of the values between given indices in a list of numeric values or elements.

Example:

Code Block
<O N="sumObject1" T="Project" Category="Functions" TransAlignRule="1">
    <!-- created by ParamML Examples on 8/22/2023 -->
    <P N="List1" V="[0,1,2,3,4,5,6,7,8,9]" />
    <P N="sumList" V="sum(List1)" />
    <P N="sumRangeList" V="sum(List1,5,6)" />
</O>
Image Added

 

As demonstrated, sumList returns the total of List1 while sumRangeList returns the sum of values between 5-6th indices of List1.

To view this example in the library, see (https://openbrim.org/app/?incubator=1&author=ParamML_Examples_OpenBrIM+Platform&obj=objidqokstqo0bi25myjlp2zo2 )