🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

compare within a list

User: "Sathish_21542"
Altair Community Member
Updated by Sathish_21542

Hi,

I have a list of elements with ids as:

set elementlist { {100 101} {1000 1001} {101 100} {1001 1000} }

I need to check for duplicate ids within the list. whichever item is existing twice should be written as output.

 

expected output:

{100 101} {1000 1001}

or

{101 100} {1001 1000}

Can anyone help me with this? 

Thanks in advance!

Find more posts tagged with

Sort by:
1 - 1 of 11
    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi

    foreach item $elementlist {

        If {[llength [lsearch -all $elementlist $item]]>1} {puts $item}

    }