• 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 simultaneously traverse varaiable number of lists...

Stats

  • Locked Locked
  • Replies 8
  • Subscribers 142
  • Views 15064
  • 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 simultaneously traverse varaiable number of lists?

archive
archive over 19 years ago

If I want to traverse, lets's say for example, 3 lists at one time, I would use:

list1 = '(1 2 3)
list2 = '(4 5 6)
list3 = '(7 8 9)
foreach((x y z) list1 list2 list3
printf("%L %L %L\n" x y z)
)
But, how do you do this, when you don't know how many lists that you will need to traverse? Is this easily done in SKILL? Or, will I have to brute force it using elemental list access, like so?
listOfLists = '((1 2 3) (4 5 6) (7 8 9))
for(j 1 length(car(listOfLists))
string = ""
foreach(l listOfLists
string = sprintf(nil "%s %L" string nthelem(j l))
)
printf("%s\n" string)
)
Do you know a better way?  Please remember that I do not know the number of lists in the listOfLists a priori (although I do know the lists are all the same length); otherwise, I would use the structure from the first example ...

Thanks!


Originally posted in cdnusers.org by m27315
  • Cancel
Parents
  • archive
    archive over 19 years ago

    Apologies, I should have used the "Quote" button at the top - my code has had the indentation stripped as a result. It should have been:

    apply('mapc
    `(lambda((@rest entries)
    let((string)
    string=""
    foreach(entry entries string=sprintf(nil "%s %L" string entry))
    printf("%s\n" string)
    ) ; let
    ); lambda
    ,@listOfLists
    ) ; end of backquote list
    ) ; apply


    and:

    apply('mapc
    cons(lambda((@rest entries)
    let((string)
    string=""
    foreach(entry entries string=sprintf(nil "%s %L" string entry))
    printf("%s\n" string)
    ) ; let
    ); lambda
    listOfLists
    ) ; cons
    ) ; apply

    Regards,

    Andrew.


    Originally posted in cdnusers.org by adbeckett
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • archive
    archive over 19 years ago

    Apologies, I should have used the "Quote" button at the top - my code has had the indentation stripped as a result. It should have been:

    apply('mapc
    `(lambda((@rest entries)
    let((string)
    string=""
    foreach(entry entries string=sprintf(nil "%s %L" string entry))
    printf("%s\n" string)
    ) ; let
    ); lambda
    ,@listOfLists
    ) ; end of backquote list
    ) ; apply


    and:

    apply('mapc
    cons(lambda((@rest entries)
    let((string)
    string=""
    foreach(entry entries string=sprintf(nil "%s %L" string entry))
    printf("%s\n" string)
    ) ; let
    ); lambda
    listOfLists
    ) ; cons
    ) ; apply

    Regards,

    Andrew.


    Originally posted in cdnusers.org by adbeckett
    • 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