how to sum list?



  • Hi everyone(sorry for English,I can't speak English)
    How can all the "list" elements be summed up?While the number of the "list" array is constantly changing, but there is 100% of the number
    sorry again for the Google translation



  • SET VAR "MO" "0"
    FUNCTION LENGTH "<LISTNAME>" -> VAR "ML"
    SET VAR "MN" "0"
    WHILE "<MO>" NotEqualTo "<ML>"
    FUNCTION Compute "<MN>+<LISTNAME[<MO>]>" -> VAR "SUM"
    FUNCTION Compute "<MO>+1" -> VAR "MO"
    ENDWHILE

    hope didn't make errors...



  • UTILITY List "REFUND" Length -> VAR "LIST_COUNT"
    SET VAR "LIST_INDEX" "0"
    SET VAR "SUM_ARRAY" "0"
    WHILE "<LIST_INDEX>" NotEqualTo "<LIST_COUNT>"
    FUNCTION Compute "<SUM_ARRAY>+<REFUND[<LIST_INDEX>]>" -> VAR "REFUND_USD"
    FUNCTION Compute "<LIST_INDEX> + 1" -> VAR "LIST_INDEX"
    ENDWHILE

    it doesn't work, maybe I did something wrong


  • Admin

    It's way easier than that..

    • utility block -> list -> join (use + as separator) -> output to variable SUM
    • function block -> compute -> input is <SUM> and it will print out the sum


  • Thank you very much for your help,the last message helped
    and once again I apologize for the English language


Log in to reply