• 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. Custom IC SKILL
  3. how to remove repeat element in a list

Stats

  • Locked Locked
  • Replies 13
  • Subscribers 145
  • Views 23646
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to remove repeat element in a list

tomchen
tomchen over 12 years ago

Hi 

I want to remove repeated element that in a list, but I can't find the related function for this.

I try to use hash table to solve it , but the order of this list will be changed

does any other function for this ??

ex:

                                                      change to 

aa= list("AA" "AA" "AA" "BB" "BB")  -----------------> aa = list("AA" "BB)

 

  • Cancel
Parents
  • jimka
    jimka over 11 years ago

    Hi Andrew, I agree that the fastest way to remove duplicates is using a hash table.  But a warning should sit above such a function as CCFuniqueInOrder.  One must be sure that the unbound symbol is not in the list being examined.  The unbound symbol is indeed likely to appear in the list if your application is operating on SKILL code.  E.g., if you are trying to find all the symbols in your SKILL code for the purpose of examining function prefixes etc.

    Another limitation of hash tables is that not all SKILL data types are valid hash keys.  Three types come to mind quickly.  CDF objects (such as returned from cdfGetInstCDF), PCRE compiled expressions (such as returned from pcreCompile), and hash tables themselves.  If you attempt to use CCFuniqueInOrder to remove duplicates from a given list of hash tables, i.e., a list of hash tables which might contain the same hash table more than once, then uniq[elem] will trigger an error.

    For example:

     (let ((x (makeTable 'x)) (y (makeTable 'y))) (CCFuniqueInOrder (list x x y y)))
    *Error* assoc hash: given user type is not supported in assoc tables - table:x
    <<< Stack Trace >>>
    uniq[elem]
    boundp(uniq[elem])
    !boundp(uniq[elem])
    (!boundp(uniq[elem]) && (uniq[elem] = t))
    setof(elem lst (!boundp(&) && (uniq[elem] = t)))
    let(((uniq makeTable(&))) setof(elem lst (!& && (uniq[elem] = t))))
    CCFuniqueInOrder(list(x x y y))
    let(((x makeTable(&)) (y makeTable(&))) CCFuniqueInOrder(list(x x y y)))

     

    Admittedly this case is exremely rare. Most SKILL users will never need to worry about such extreme corner case.

    Regards,

    Jim. 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • jimka
    jimka over 11 years ago

    Hi Andrew, I agree that the fastest way to remove duplicates is using a hash table.  But a warning should sit above such a function as CCFuniqueInOrder.  One must be sure that the unbound symbol is not in the list being examined.  The unbound symbol is indeed likely to appear in the list if your application is operating on SKILL code.  E.g., if you are trying to find all the symbols in your SKILL code for the purpose of examining function prefixes etc.

    Another limitation of hash tables is that not all SKILL data types are valid hash keys.  Three types come to mind quickly.  CDF objects (such as returned from cdfGetInstCDF), PCRE compiled expressions (such as returned from pcreCompile), and hash tables themselves.  If you attempt to use CCFuniqueInOrder to remove duplicates from a given list of hash tables, i.e., a list of hash tables which might contain the same hash table more than once, then uniq[elem] will trigger an error.

    For example:

     (let ((x (makeTable 'x)) (y (makeTable 'y))) (CCFuniqueInOrder (list x x y y)))
    *Error* assoc hash: given user type is not supported in assoc tables - table:x
    <<< Stack Trace >>>
    uniq[elem]
    boundp(uniq[elem])
    !boundp(uniq[elem])
    (!boundp(uniq[elem]) && (uniq[elem] = t))
    setof(elem lst (!boundp(&) && (uniq[elem] = t)))
    let(((uniq makeTable(&))) setof(elem lst (!& && (uniq[elem] = t))))
    CCFuniqueInOrder(list(x x y y))
    let(((x makeTable(&)) (y makeTable(&))) CCFuniqueInOrder(list(x x y y)))

     

    Admittedly this case is exremely rare. Most SKILL users will never need to worry about such extreme corner case.

    Regards,

    Jim. 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

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