I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t

I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are there in that Array and the output should return the unique duplicate values like {3,4}. Is there a function to gets this output?

OriginalPostID-144331

OriginalPostID-144331

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer
    I'll throw in the solution I implemented for my project, which will take an Any Type array and return just the duplicates:

    function: getArrayDuplicates()
    rule input: ri!array (Any Type)

    with(
    uniques: union(ri!array, ri!array),
    singlesIndex: if(length(ri!array) = length(uniques),
    {},
    apply(rule!whereContainsSingle, uniques, ri!array)
    ),

    if(length(ri!array) = length(uniques),
    {},
    remove(
    ri!array,
    singlesIndex
    )
    )
    )


    sub function: whereContainsSingle()
    ri!values (any type)
    ri!array (any type)

    with(
    indices: wherecontains(ri!values, ri!array),
    if(length(indices) > 1, {}, indices)
    )
Reply
  • +1
    Certified Lead Developer
    I'll throw in the solution I implemented for my project, which will take an Any Type array and return just the duplicates:

    function: getArrayDuplicates()
    rule input: ri!array (Any Type)

    with(
    uniques: union(ri!array, ri!array),
    singlesIndex: if(length(ri!array) = length(uniques),
    {},
    apply(rule!whereContainsSingle, uniques, ri!array)
    ),

    if(length(ri!array) = length(uniques),
    {},
    remove(
    ri!array,
    singlesIndex
    )
    )
    )


    sub function: whereContainsSingle()
    ri!values (any type)
    ri!array (any type)

    with(
    indices: wherecontains(ri!values, ri!array),
    if(length(indices) > 1, {}, indices)
    )
Children
No Data