Can we perform 2 operations within the same expression of a forEach loop possible? (Ex: zip in python.)
Discussion posts and replies are publicly visible
Hi sanjuktab2257
"zip in python", so based on this i read about zip function in python
So, we have a similar function in Appian: merge()And can you please explain your usecase.
Thank you Yashwanth Akula , that was helpful. It seems like "merge" is only for lists. Do you know how to merge two dictionaries.
a!localVariables( local!var1: {"John": "A", "Sam": "B", "Rose": "C"}, local!var2: {"Smith": 1, "Williams": 2, "Thompson": 3}, a!forEach(items: merge(local!var1.value, local!var2.value), expression: concat(fv!item[1], " ,", fv!item[2]) )
hi sanjuktab2257 , see if this helps.
a!localVariables( local!var1: { "John": "A", "Sam": "B", "Rose": "C" }, local!var2: { "Smith": 1, "Williams": 2, "Thompson": 3 }, local!var1Values: a!flatten( a!forEach( items: a!keys(local!var1), expression: if( fv!isLast, stripwith(keyval(local!var1, fv!item, ":", ","), "]"), keyval(local!var1, fv!item, ":", ",") ) ) ), local!var2Values: a!flatten( a!forEach( items: a!keys(local!var2), expression: if( fv!isLast, stripwith(keyval(local!var2, fv!item, ":", ","), "]"), keyval(local!var2, fv!item, ":", ",") ) ) ), merge(local!var1Values, local!var2Values))
Merge the keys first. Example:
a!localVariables( local!var1: { "John": "A", "Sam": "B", "Rose": "C" }, local!var2: { "Smith": 1, "Williams": 2, "Thompson": 3 }, a!forEach( items: merge(a!keys(local!var1), a!keys(local!var2)), expression: concat( local!var1[fv!item[1]], ",", local!var2[fv!item[2]], ) ) )