• 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. list substitution problems

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 13987
  • 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

list substitution problems

sparksu
sparksu over 16 years ago

I have a long list here:

listA=list(P1 P2 P3 ... Px-1 Px Px+1 ... Pn)

for a given Px, I want to substitute Px with 2 new elements Px1 Px2  :

ListB=list(P1 P2 P3 ... Px-1 Px1 Px2 Px+1 ... Pn)

I know how to do it using "reverse()" function.

But based on SKILL Language User Guide, reverse() can generate a lot of memeory.

Is there a more efficient way to do this? I don't care if it is destructive or nondestructive.

Here is my code using reverse():

;---------------------------------------------------------------------------------------------------------------------------------

listB2=rplaca(member(Px listA) Px2)                                     ;listB2=>list(Px2 ... Pn)

listB1=reverse(rplaca(member(Px2 reverse(listA) Px1)             ;listB1=>list(P1 P2 P3 ... Px-1 Px1)

listB=append(listB1 listB2)                ;ListB=>list(P1 P2 P3 ... Px-1 Px1 Px2 Px+1 ... Pn)

;---------------------------------------------------------------------------------------------------------------------------------

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 16 years ago

    match=member(Px listA)
    listB=
      if(eq(match listA) then
        constar(Px1 Px2 cdr(listA))
      else
        rplaca(match Px1)
        rplacd(match cons(Px2 cdr(match)))
        listA
      )

    You also should consider whether a list is the right data structure for your needs - I presume whatever you are doing needs to be ordered, otherwise you could have just stuck Px2 on the beginning. Or used a table.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 16 years ago

    match=member(Px listA)
    listB=
      if(eq(match listA) then
        constar(Px1 Px2 cdr(listA))
      else
        rplaca(match Px1)
        rplacd(match cons(Px2 cdr(match)))
        listA
      )

    You also should consider whether a list is the right data structure for your needs - I presume whatever you are doing needs to be ordered, otherwise you could have just stuck Px2 on the beginning. Or used a table.

    Regards,

    Andrew.

    • 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