My list is [0.10, 0.20, 0.30], how do I get the total sum of the list(0.60)?
Assuming you have a list of strings, this is an example
BLOCK:ConstantList
value = ["0.10", "0.20", "0.30"]
=> VAR @list
ENDBLOCK
float sum = list.Select(i => float.Parse(i)).Sum();
1 Like
Should I change the list.Select to my variable name? How can I make the sum a variable so I can parse/capture it?
Yes change only list
(not Select
) with the name of your list variable.
The output is already inside a variable called sum
as you can see, so you can just add that to capture.
float sum = myListVariable.Select(i => float.Parse(i)).Sum();
data.MarkForCapture(nameof(sum));
Can you please give me some LoliCode that creates the list and replicates the issue?
1 Like