Is it possible to make foreach pair in SKILL?

  • Thread starter Reotaro Hashemoto
  • Start date
R

Reotaro Hashemoto

Guest
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 wrote, on 09/09/09 13:02:
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
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.
 

Welcome to EDABoard.com

Sponsor

Back
Top