gusl: (Default)
[personal profile] gusl
One programming annoyance when writing loops is wanting to access each element of the list without passing the index, i.e. with code like: for (el in list) while simultaneously wanting to know the index without writing i=0 and i++.

I'm not aware of any solutions to this in current usage.

(no subject)

Date: 2010-04-28 04:06 am (UTC)
From: [identity profile] fare.livejournal.com
Yes, one loop during which the index increases as the elements of the list are enumerated.

If you want to nest, you can have a (loop ...) inside a (loop ...).

(no subject)

Date: 2010-04-28 04:08 am (UTC)
From: [identity profile] fare.livejournal.com
Note that the Common Lisp LOOP facility is very nice in some ways, has somewhat extensible implementations, but has weird limitations and unniceties when you want advanced usage.

See Olin Shivers' LOOP (for Scheme) for the best LOOP story ever.

February 2020

S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526272829

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags