Hi All,
Can you please help me how to get the intersection of Lists of array (number array). So I have a list of number array which I construct in the interface. I need to only pick the common element present in all the number array . I tried with loop and reduce function but not getting the actual result .
It has been achieved by taking an array element and loop over other other array and check if present in all array then keep it or remove it which I feel is very dirty way of doing .
Any suggestion would be appreciated.
Thanks
Manish
Discussion posts and replies are publicly visible
https://docs.appian.com/suite/help/22.3/fnc_set_intersection.html
Hi Stefan,
I have tried intersection with reduce function but not able to achieve it as list of number array generate at runtime and I am not able to pass it like an arguments.
[{1,2,3},{2,3,4},{4,5,6}]
Why do you need reduce to do that?
intersection({1,2,3,4},{2,3,4},{4,5,6})
returns 4, which is the only number present in all the arrays.
The list of Array generates at run time , How will I pass the list of array to intersection function ? , So I tried to used the reduce function to send the result of intersection for next iteration(interaction).
Manish_Kumar said:generates at run time
Can you clarify what you mean by this? What's the underlying code here?
a!localVariables( local!arrays: a!forEach( items: enumerate(1 + rand() * 10), expression: a!map( list: 1 + enumerate(rand() * 10) ) ), reduce( rule!SSH_Intersect(a:_, b:_), local!arrays[1], ldrop(local!arrays, 1) ) ) rule!SSH_Intersect(a (map), b(map)) a!map( list: intersection(ri!a.list, ri!b.list) )
Using just arrays does not work. I assume there is some undefined/weird behaviour inside reduce when feeding it with lists of lists.
Unknown said:lists of lists
come on - you should already know that appian almost completely refuses to nicely handle lists-of-lists in the first place ;-)
True, still hoping .... The weird thing is, that, using just lists, it works sometimes, and sometimes it throws a weird error message.
Thanks everyone for your inputs.
Could you let me know how you have addressed this issue, as we are also facing the same issue
Did you try the solution I posted?
Ohh yes its working thank you.