Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Suggested Answer
+1
person also asked this
people also asked this
Replies
14 replies
Answers
2 answers
Subscribers
10 subscribers
Views
20862 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t
fariaj
over 10 years ago
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
Top Replies
Thenmozhi Mohanakrishnan
over 7 years ago
+2
Certified Senior Developer
load( local!a: {1,2,3,4,4,5,3}, remove(local!a,a!forEach( items: union(local!a,local!a), expression: wherecontains(fv!item,local!a)[1] )) )
Josh
over 6 years ago
in reply to
davel001150
+2
Certified Lead Developer
It is not correct based on the example provided in the original question. I'm glad it helped you out, though.
Josh
over 6 years ago
in reply to
Mike Schmitt
+1
Certified Lead Developer
See you in 18 months for another thread revival.
Parents
+1
Mike Schmitt
Certified Lead Developer
over 10 years ago
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)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Reject Answer
Cancel
Reply
+1
Mike Schmitt
Certified Lead Developer
over 10 years ago
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)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Reject Answer
Cancel
Children
No Data