OriginalPostID-144331
Discussion posts and replies are publicly visible
Not that this thread isn't already ancient, but since it's been brought back up, I'll post the updated version of my old function that gets duplicate array members (now we have a!forEach and don't require sub-functions).
Note: this funciton returns ALL duplicate members, i.e. any and all array members that have a duplicate anywhere else in the array. If the need is for a list where each duplicate member appears only once, this result can be further de-duplicated.
with( local!uniqueMembers: rule!GLBL_removeDuplicateArrayMembers( array: ri!array ), /* note: this funciton does "union(ri!array, ri!array)". it's useful to have as a global function. */ local!indicesIfMultiple: a!forEach( items: local!uniqueMembers, expression: with( local!indices: wherecontains( fv!item, ri!array ), if( rule!APN_arrayLength(local!indices) > 1, local!indices, {} ) ) ), index( ri!array, sort(local!indicesIfMultiple), {} ) )
I do apologize, but for the sake of others I have to call out my alarm at a suggested answer which features the undocumented sort() function. (I don't understand why such a thing wouldn't be documented, but there you go)
fair enough - though if anyone is concerned with using sort() as in my example, they may simply replace this with their own expression rule that sorts via officially supported functionality, i.e. passing an array through toDataSubset with a sorting parameter added.
See you in 18 months for another thread revival.