Counting from zero

Stéphane Rollandin lecteur at zogotounga.net
Tue May 2 07:15:48 UTC 2006


Duncan Mak wrote:
> I was in a compiler class and was doing a project in Scheme. Like the style
> prefered by Smalltalk, I strived to use only higher-order functions, like
> map, instead of doing explicit iterations (Scheme makes that hard anyhow).
> 
> However, I ran into trouble when I had to iterate two collections together,
> but each at a different offset, i..e  matching a[i] to  b[i + 2].

I believe the loop macro is implemented in Scheme; it makes this kind of 
iterations very easy.

loop for i in list-a
      for j in (cddr list-b)
      do (your-thing i j)

and you're done


Stef



More information about the Squeak-dev mailing list