| Author |
Message |
Svenn Are Bjerkem
Guest
|
Posted:
Wed Nov 02, 2005 5:10 pm Post subject:
Simple skill problem |
|
|
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
|
|
| Back to top |
|
 |
Trevor Bowen
Guest
|
Posted:
Wed Nov 02, 2005 9:10 pm Post subject:
Re: Simple skill problem |
|
|
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
Svenn Are Bjerkem wrote:
| Quote: | 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.
|
|
|
| Back to top |
|
 |
satya
Guest
|
Posted:
Wed Nov 02, 2005 9:10 pm Post subject:
Re: Simple skill problem |
|
|
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?
|
|
| Back to top |
|
 |
Ed "Mr. Diva" Kalenda
Guest
|
Posted:
Wed Nov 02, 2005 9:10 pm Post subject:
Re: Simple skill problem |
|
|
On Wed, 2 Nov 2005 17:14:40 +0100, Svenn Are Bjerkem
<svenn.are@bjerkem.de> wrote:
| Quote: | 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.
|
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. |
|
| Back to top |
|
 |
Svenn Are Bjerkem
Guest
|
Posted:
Fri Nov 04, 2005 9:10 am Post subject:
Re: Simple skill problem |
|
|
In article <ih2im1lo6bgoa7h9i83imsu96sfg0k85ii@4ax.com>,
diva@cadence.com says...
| Quote: | 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)
)
|
As a tcl'er I should have known ...
Thanks
--
Svenn |
|
| Back to top |
|
 |
|
|
|
|