Get the intersection of list of array

Certified Senior Developer

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

Parents Reply
  • 0
    Certified Lead Developer
    in reply to Manish_Kumar

    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.

Children