Finding repeated items in an array

Hi All,

I have an array 1,2,3,3,5,6

In this I want the repeated value which is 3 as output.

Can you please suggest which is the approach to be followed.

TiA

Harsha

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi Harsha,

    Please find the code snippet demonstrating one of the approach to achieve your requirement below:

    load(
      local!items_int: {1, 2, 3, 3, 4, 5, 4, 6},
      local!res,
      local!content: a!forEach(
        local!items_int,
        if(
          count(wherecontains(fv!item, local!items_int)) > 1,
          append(local!res, fv!item),
          append(local!res, {})
        )
      ),
      union(
        local!content,
        local!content
      )
    )
    
    /* OUTPUT:  3, 4  (Type: List of Number (Integer) ) */

    Hope this will help you.

Reply
  • 0
    Certified Lead Developer

    Hi Harsha,

    Please find the code snippet demonstrating one of the approach to achieve your requirement below:

    load(
      local!items_int: {1, 2, 3, 3, 4, 5, 4, 6},
      local!res,
      local!content: a!forEach(
        local!items_int,
        if(
          count(wherecontains(fv!item, local!items_int)) > 1,
          append(local!res, fv!item),
          append(local!res, {})
        )
      ),
      union(
        local!content,
        local!content
      )
    )
    
    /* OUTPUT:  3, 4  (Type: List of Number (Integer) ) */

    Hope this will help you.

Children
No Data