How to get the duplicates from an array:
i/p:{1,2,2,3,3}o/p:{2,3}
Discussion posts and replies are publicly visible
Hi, Please try to use this
a!localVariables( local!a:{1,2,2,3,3}, a!flatten(a!forEach( items: union(local!a,local!a), expression: if( length(wherecontains(fv!item,local!a))>1, fv!item, {} ) )) )
This seems to work, too.
a!localVariables( local!input: { 1, 2, 2, 3, 3 }, local!output: index(local!input, a!forEach(union(local!input, local!input), index(wherecontains(fv!item, local!input), 2, {}))), local!output )
Don't use, but it may be of interest:
a!localVariables( local!input: { 1, 2, 2, 3, 3 }, local!output: index(local!input, where(a!forEach(local!input, fv!index>wherecontains(fv!item, local!input)[1]))), local!output )
Note this last example will need a union() on the local!output as it duplicates values with more than 2 occurrences.