How can we get 1st index elements of each array in different new array. Like{2,13,65}{7,15,45}{14,3,56}So output of 1st elements should be {2,7,14}And for 2nd and 3rd {13,15,3}{65,45,56}
Discussion posts and replies are publicly visible
Appian doesn't really understand list of list and therefore it will flatten them into one big array. You might have to cast it in a dictionary so it can iterate on that.
a!localVariables( local!array:{ { list: {2,13,65} }, { list: {7,15,45} }, { list: {14,3,56} } }, a!forEach( items: local!array, expression: fv!item.list[1] ) )
You can change the value of 1 to your desired index.
for getting all the three arrays as desired/required
a!localVariables( local!array:{ { list: {2,13,65} }, { list: {7,15,45} }, { list: {14,3,56} }, { list: {1,2,3} } }, a!forEach( items:enumerate(3)+1, /* three is the no. arrays you have to make/ output arrays */ expression: a!localVariables( local!temp:fv!item, a!forEach( items: local!array, expression: fv!item.list[local!temp] ))) )
What is the point of copy-pasting the entire code but with increased complexity - one more a!forEach()? That just adds more executing time.
Sir, as he said in the question that he wants n(3) arrays accordingly .. so I thought what if the arrays are {1,2,3,4,.....,n} ... So i've edited your code with one extra loop in which he can put the number of required arrays for output. eg - [1,2,3] , [2,4,6], [4,8,9] should be [1,2,4],[2,4,8],[3,6,9] so i've added an extra loop for getting all the arrays as - if you put 2 in the first loop than you can get only [1,2,4],[2,4,6]. and same will work for the n times with a index function also.please correct me if I'm wrong
Ah, okay! Then it makes sense.
a!localVariables( local!merger: merge({ 2, 13, 65 }, { 7, 15, 45 }, { 14, 3, 56 }), local!merger )