Is it possible to make foreach pair in SKILL?

Discussion in 'Cadence' started by Reotaro Hashemoto, Sep 9, 2009.

  1. Hi,

    I've a sting in an ASCII file like this:
    myList='(
    (aa aaa)
    (bb bbb)
    (cc ccc)
    ...
    )

    I loaded the file, so that, I'm assumed to have myList defined

    I want to make a loop over each pair like this:

    foreach( (first second) myList
    printf("---- %L---- %L -----\n" first second)
    )

    This is not working because forach first argument must be of type 's'

    I have tried:
    foreach( pair myList
    first=car(pair)
    second = cdr(pair)
    printf("---- %L---- %L -----\n" first second)
    )

    the output is what I need, but with an error at the end:
    "*Error* car: argument #1 should be a list (type template = "l")
    - ..."

    What does that mean? How to fix?

    Thanks,
    Ahmad
    I've tried it the same way as I described above, but is giving syntax
    error
     
    Reotaro Hashemoto, Sep 9, 2009
    #1
  2. Reotaro Hashemoto wrote, on 09/09/09 13:02:
    Ahmad,

    The form:

    foreach((first second) ...)

    works if you have two lists to traverse. You can do:

    foreach((first second) firstList secondList
    ...
    )

    The reason why your approach fails must be because myList is not of the form
    that you say at the end of the list. Look at the end of myList, and check that
    it is pairs of entries all the way through - that must be the reason for the
    failure.

    Regards,

    Andrew.
     
    Andrew Beckett, Sep 10, 2009
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.