Simple skill problem

Discussion in 'Cadence' started by Svenn Are Bjerkem, Nov 2, 2005.

  1. Hi,

    I have some basic problem with SKILL

    I have 3 lists, each equally long containing values. Now I want to print
    them out. I tried

    (foreach crossed rx_cross
    (printf "%L %L %L\n" crossed (car tx_cross) (clk_cross))

    but because car is not destructive, I always get the first element of
    tx_cross list and clk_cross list. I looked into the manual and tried to
    find some examples solving this kind of problem, but my problem is that
    I simply don't understand SKILL good enough to find a fitting command.
     
    Svenn Are Bjerkem, Nov 2, 2005
    #1
  2. Svenn Are Bjerkem

    satya Guest

    Would (mapc (lambda (a b c) (printf "%s %s %s\n" a b c)) crossed
    (car tx_cross) (clk_cross)) be what you are looking for?
     
    satya, Nov 2, 2005
    #2
  3. Svenn Are Bjerkem

    Trevor Bowen Guest

    Ahh, this is one of my favorite tricks:

    foreach can iterate through multiple lists at the same time, even lists
    of different lengths. For example:

    l1 = list(1 2)
    l2 = list(5 6 7)
    l3 = list(9 10 11 12)

    RC = foreach((x y z) l1 l2 l3
    printf("%L %L %L\n" x y z)
    )
    printf("RC = %L\n" RC)

    -> Prints the following:

    1 5 9
    2 6 10
    RC = (1 2)

    Notice that it stopped when the first list was exhausted. However, this
    trick only works one way. That is it works when:

    length(l1) <= length(l2) <== length(l3)

    But not when:

    length(l1) > length(l2) > length(l3)

    HTH
     
    Trevor Bowen, Nov 2, 2005
    #3
  4. Read the SKILL Language Reference for foreach. I believe you want to use
    the second syntax form:

    foreach( (a b c) list1 list2 list3
    printf("%L %L %L\n" a b c)
    )

    Ed "Mr. Diva" Kalenda
    Cadence Design Systems

    This is just me blathering, not the company, since they don't let talk for them.
     
    Ed Mr. Diva Kalenda, Nov 2, 2005
    #4
  5. As a tcl'er I should have known ...

    Thanks
     
    Svenn Are Bjerkem, Nov 4, 2005
    #5
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.