Home > Community > Forums > PCB SKILL > Remove repeat item from a list

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Remove repeat item from a list 

Last post Fri, Feb 24 2006 12:08 AM by archive. 5 replies.
Started by archive 24 Feb 2006 12:08 AM. Topic has 5 replies and 2551 views
Page 1 of 1 (6 items)
Sort Posts:
  • Fri, Feb 24 2006 12:08 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    Remove repeat item from a list Reply

    I have tried some way to remove some repeat item from a list.
    Followed is the simple one

    foreach(item list
    list=cons(item remove(item list))
    )

    Do anyone have a more available command or fuction?


    Originally posted in cdnusers.org by leonlee
    • Post Points: 0
  • Fri, Feb 24 2006 7:19 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: Remove repeat item from a list Reply

    This is what I use...

    procedure(_removeDuplicates(masterList)
    let((finalList)
    foreach(item masterList
    unless(member(item car(finalList))
    finalList=tconc(finalList item)
    )
    )
    finalList
    )
    )

    If your are going through a list of dbids, then you can use memq instead of member to speed this up.


    Originally posted in cdnusers.org by natebizu
    • Post Points: 0
  • Wed, Apr 12 2006 12:20 PM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: Remove repeat item from a list Reply

    I use "makeTable" because it doesn't accept duplicates.


    below is code from a program I wrote called highlight_padstacks.il that is in the downloadable user skill zip file from cadence. I make a list by selecting all pins and via, and then load the names into a table.

    padstacklist=makeTable("atable1" 0) 

    axlSetFindFilter(?enabled list("noall" "pins" "vias")
             ?onButtons list("noall" "pins" "vias"))
    axlAddSelectAll()
    pin_list = axlGetSelSet()

    foreach(pin_db pin_list
             
      padstack_db = pin_db->definition     ;Extract PadstackID from pinID
      pad_name=padstack_db->name      ;Extract Padstack Name from PadstackID
      padstacklist[pad_name]=pad_name  ;Load into table as Name:Value
                                                                   
    );end foreach


    Originally posted in cdnusers.org by Geoffm
    • Post Points: 0
  • Thu, Jan 18 2007 12:49 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: Remove repeat item from a list Reply

    Now I use below code to this solution:

    procedure( RemoveDuplicateItem(A)
    B=nil
    while(A!=nil B=cons(nth(0 A) B) A=remove(nth(0 A) A))
    B
    );procedure


    Originally posted in cdnusers.org by leonlee
    • Post Points: 0
  • Thu, Jan 18 2007 1:17 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: Remove repeat item from a list Reply

    You could try using the unique function

    For example, this will weed out all duplicate via names from a list:

    via_name_list = unique(sort( via_name_list 'alphalessp))


    A more-generic-but-trickier method involves using a foreach loop and the member funtion.
    Someting like:


    ulist = nil
    foreach( obj obj_list
    unless( member( obj ulist)
    ulist = cons( obj ulist)
    );end-unless
    );end-foreach



    HTH,

    Chris Walters
    local Cadence guru
    ()

    PS - anyone know of a position for a(nother) Cadence guru?



    Originally posted in cdnusers.org by kerchunk
    • Post Points: 0
  • Thu, Jan 18 2007 6:10 PM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: Remove repeat item from a list Reply

    It's wonderful for the unique function. which user guide offers these functions?

    I don't know the Cadence guru position. where~~


    Originally posted in cdnusers.org by leonlee
    • Post Points: 0
Page 1 of 1 (6 items)
Sort Posts:
Started by archive at 24 Feb 2006 12:08 AM. Topic has 5 replies.