I know that in groovy if
list = [1,2,3,1]
when
list.unique()
with return
[1,2,3]
But if I want to find a duplicate value for duplicate, inconsistent items in a list. How can i do this?
detect([1,2,3,1]) => true detect([1,2,3,2]) => true detect([1,1,2,3]) => false detect([1,2,2,3,3]) => false detect([1,2,3,4]) => false
Thanks.
Edit: add these two cases
detect([1,2,2,1]) => true detect([1,2,1,1]) => true
true means that any non-sequential duplication occurs.
source share