input : {{1,3},{2,3},{4,5},{5,6}}
output : {3,6,20,30}
We have to get product of each item(i.e list) in the array.
Please help me out with this issue
Discussion posts and replies are publicly visible
Hi vickyr0501 ,
i tried solving the above problem with a foreach(). here is my code.
a!localVariables( local!input: { { 1, 3 }, { 2, 3 }, { 4, 5 }, { 5, 6 } }, local!even: a!forEach( items: local!input, expression: if(mod(fv!index, 2) = 0, fv!item, {}) ), local!odd: a!forEach( items: local!input, expression: if(mod(fv!index, 2) = 0, {}, fv!item) ), a!forEach( items: local!odd, expression: fv!item * (index(local!even, fv!index, 0)) ) )
Really, everything we need to know about how appian (fails to) handle list-of-lists can be seen with how it resolves the value stored in local!input:
The only exception I've ever really seen to the above is how the result of merge() is treated - because for whatever reason, list-of-list data seems to be honored (to a certain extent) in this context (and perhaps this context alone). It's very frustrating since merge() is pretty unintuitive to understand and to use for real-world cases.