• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Allegro X PCB Editor
  3. Duplicate Values in list

Stats

  • Replies 6
  • Subscribers 159
  • Views 15404
  • Members are here 0
More Content

Duplicate Values in list

vimaldevlpr
vimaldevlpr over 4 years ago

Hi,

I want to get duplicate values present in list using skill programming.

A = ("A1" "A2" "A1" "BB1" "BB3" "A1" "BB1")

In this list I want to get repeated values 

result = "A1" "BB1"

I used "!unique" Command shows me nil

Can anyone please guide me how to get

  • Sign in to reply
  • Cancel
  • DavidJHutchins
    DavidJHutchins over 4 years ago

    Try the ListDupes shown below:

    > pp ListDupes
    procedure(ListDupes(l)
    if(l
    if(member(car(l)
    cdr(l)
    )
    cons(car(l)
    ListDupes(remove(car(l)
    cdr(l)
    )
    )
    )
    ListDupes(remove(car(l)
    cdr(l)
    )
    )
    )
    )
    )
    nil
    > ListDupes( A )
    ("A1" "BB1")
    >

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • vimaldevlpr
    vimaldevlpr over 4 years ago in reply to DavidJHutchins

    Hi David thanks for your reply..

    I don't know how to apply yours code in this categories can you guide me please..

    I have list of datas in list in that want to check only the "car(list)" duplicates in the list.

    Example:

    input file:

    inpswap.lst:

    116.14,AAA,AAA1
    116.14,BBB,BBB1
    130.14,AAA,AAA1
    218.07,DDD,DDD1
    112.1,DDD,DDD1
    218.07,EEE,EEE1
    116.14,FFF,FFF1

    code :

    procedure(swaplistkar()
     swapinp = infile("inpswap.lst")
     swaplst = nil
     swapdupnum = nil
     while(gets(swaplp swapinp)
       swaplp = car(parseString(swaplp "\n"))
      when(swaplp push(swaplp swaplst))
      )
      close(swapinp)
     foreach(swploop swaplst
      swpparse = car(parseString(swploop ","))
       
      
      ; The code I want to find duplicates
      
     )
    )

    my output want to be:

    116.14,BBB,BBB1

    218.07,EEE,EEE1

    116.14,FFF,FFF1

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • luanvn81
    luanvn81 over 4 years ago in reply to vimaldevlpr

    Hi V !

    You can try this code, it's repaired from your code and base on your result.

    axlCmdRegister("swaplistkar" `swaplistkar)
    procedure(swaplistkar()
    swapinp = infile("inpswap.lst")
    swaplst = nil
    swapdupnum = nil
    while(gets(swaplp swapinp)
    swaplp = car(parseString(swaplp "\n"))
    when(swaplp push(swaplp swaplst))
    );end while
    close(swapinp)

    foreach(item swaplst
    if(length(setof(el swaplst cdr(parseString(el ",")) == cdr(parseString(item ",")))) == 1 then
    printf("%L\n", item)
    );end if
    );end foreach
    )

    Luan.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • vimaldevlpr
    vimaldevlpr over 4 years ago in reply to luanvn81

    Hi luan,

    Kindly thanks..

    In this case how to find Duplicates of " 2nd element in list"

    As like above case older we checked by 1 element in list now how to check 2nd element in list could you please tell me.

    sample input:

    116.14,AAA,AAA1
    117.14,BBB,BBB1
    130.14,AAA,AAA2
    218.07,DDD,DDD1
    112.1,DDD,DDD2
    219.07,EEE,EEE1
    114.14,FFF,FFF1

    output :

    130.14,AAA,AAA1

    112.1,DDD,DDD2

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • luanvn81
    luanvn81 over 4 years ago in reply to vimaldevlpr

    Hi V!

    I think you can replace row code  if(.... then     by  if(length(setof(el swaplst nth(1 parseString(el ",")) == nth(1 parseString(item ",")))) > 1 then

    Luan.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
>
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information