• 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. can't reorganizing a list

Stats

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

can't reorganizing a list

bloodwayn
bloodwayn over 14 years ago

 hi,

what could be the reason that the functions "reverse" and "sortcar" do not work?!

my list normally consist of other list elements which include parameters you can see in the two following codelines. 

pos = list(field_count xButtomLeft yButtomLeft xUpperRight yUpperRight)
l_pos = cons(pos l_pos)

the field_count is an integer starting at 0. the other values are coordinates of a rectangle.
these function is called multiple times. so at the end l_pos can looks like:

l_pos = ((4 7657.6 4641.6 8657.6 5527.0) (3 7657.6 3641.6 8657.6 4641.6) (2 7657.6 2641.6 8657.6 3641.6) (1 7657.6 1641.6 8657.6 2641.6))

now i need the list in inverse form. i try it with

a) reverse(l_pos) ... nothing has change

b) sortcar( l_pos ' lessp) ... the result is l_pos = ((4 7657.6 4641.6 8657.6 5527.0))

but if i transcribe the list into another like l_bla and apply the functions on the new list....it works.
i have no idea why it happens

regards,
philip

 

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 14 years ago

    Hi Philip,

    This is due to you needing to understand that most operations in SKILL are what are called "non-destructive". This means that if you do (for example:

    l1='(1 2 3 4)
    l2='(5 6 7 8)
    append(l1 l2) => (1 2 3 4 5 6 7 8)

    but the lists l1 and l2 will not have changed. This is to avoid "side effects", and also to be more efficient. So for example, if I was to do:

    l3=l2

    Both l3 and l2 are pointing at the same data in memory - and since most list functions do not modify the lists in place, I can use the variables l3 and l2 quite safely.

    The same is true with the reverse function. If you were to look at the return value of reverse(l_pos) you would see that the list was reversed - but it did not touch the original list. You'd have to do: l_pos=reverse(l_pos) to do that - then it should work fine.

    Note however that sortcar  is a destructive function (this is highlighted in the documentation). For efficiency reasons, the sort is done in place. Because of this, your variable l_pos may change after the operation. What actually happens is that the first value that the variable points to will continue to be the first value in the resulting list. So if you did:

    l4='(4 1 2 5 6 3)
    sort(l4 'lessp) => (1 2 3 4 5 6)
    l4 => (4 5 6)

    What this means is:

    1. You need to be aware of the fact that sort/sortcar etc are destructive and so can have side effects
    2. You should always use the return value of sort/sortcar rather than relying on the fact that it will destructively modify the list passed to the sort function. 

    So if you do:

    l_pos=sortcar(l_pos 'lessp)

    it will do what you want.

    I'm not sure how copying the list into l_bla would alter any of this. I'm not sure how you "transcribed" it.

    Regards,

    Andrew.

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • bloodwayn
    bloodwayn over 14 years ago

    hi andrew,

    very thanks and ... i was slow on the uptake(is this right in english^^). sure...l_pos = reverse(l_pos) .... i don't know why i missed out the "l_pos="  =)

    so thanks for that really good description and it answered my question.

    transcribe i thought was the englisch meaning to write data from one poin to another?! ... like from one list to another list.
    and i realize this with a simple for loop

    regards,
    philip

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 14 years ago

    "slow on the uptake" is correct English ;->

    I knew what you meant by "transcribe" - just not exactly how you'd done the transcription. I hope it wasn't a for loop, because that's not a good way of dealing with a list. It would have been OK if you'd done newList=foreach(mapcar item oldList item) or better still newList=copy(oldList) - but even then, I don't see how it would have fixed the problem!

    Regards,

    Andrew.

    • 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