• 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. Lists: remove number X element

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 143
  • Views 17314
  • 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

Lists: remove number X element

Ionutz
Ionutz over 12 years ago

 Hi,

 

 Is there a way to remove a specific element from a list by knowing his location in the list and specifying to remove the elment from that location? :(

 Thank U,

Ionut

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 12 years ago

    One way would be to do:

    procedure(CCFremoveByIndex(lst n)
      let(((count 0))
        setof(elem lst (count++!=n))
      )
    )

    The second argument is the position to remove, where 0 is the first entry in the list.

    Another alternative is to use destructive methods:

    procedure(CCFremoveByIndex(lst n)
      let((remainder)
        if(zerop(n) then
          cdr(lst)
        else
          remainder=nthcdr(n-1 lst)
          rplacd(remainder cddr(remainder))
          lst
       )
      )
    )

    I've not profiled these, but the second generates less garbage, because it modifies the list in place, whereas the first constructs a new list.

    That said, it's a slightly odd thing to do - generally if you're accessing lists via a numbered index, it often means you're using the wrong approach. Lists are sequential data structures, and so are not really well suited to be accessed in a "random access" manner.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Ionutz
    Ionutz over 12 years ago

     Hi Andrew,

     

     Thank U for the feedback... just started using Skill and am a bit confused when U say "wrong approach" to access lists via an index :(

     What I have at the moment are two lists: first with the main elements and second with parametter for each element in the first list (same index in the lists). When accessing element X from first list, I am also reading element 3 from second list to use the pair.

      With the remove option, all I really want is to make sure that I can access element 3 from both lists and remove them accordingl.

     From your experience, is there any risk that the list will not keep the order of the elements as they were added to the lists? :(

     

     Thank U,

    Ionut

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

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