11 Apr 2010 15:32

```The document at http://common-lisp.net/project/iterate/ uses this as an example of the superiority of
iterate over loop:

Finding the longest list in a list of lists:

(iterate (for elt in list-of-lists)
(finding elt maximizing (length elt)))

whereas the example of how it can be done in loop is long and contorted. But loop can do

(loop for elt in list-of-lists
maximizing (length elt))

The example in 3.2 Named blocks may be better as a selling point:

(iter outer (for i below (array-dimension ar 0))
(iter (for j below (array-dimension ar 1))
(in outer (collect (aref ar i j)))))

showing that the outer loop can easily collect data produced in the inner loop.

Eivind

```
11 Apr 2010 18:57

```2010/4/11 Eivind Midtgård <eivind <at> autosim.no>:
> (iterate (for elt in list-of-lists)
>         (finding elt maximizing (length elt)))
>
> whereas the example of how it can be done in loop is long and contorted. But loop can do
>
> (loop for elt in list-of-lists
>      maximizing (length elt))

Your loop example returns the length of the longest sublist. The
Iterate example yields the longest sublist itself. I am afraid the
loop equivalent really has to be this contorted.

> The example in 3.2 Named blocks may be better as a selling point:
>
> (iter outer (for i below (array-dimension ar 0))
>             (iter (for j below (array-dimension ar 1))
>                   (in outer (collect (aref ar i j)))))
>
> showing that the outer loop can easily collect data produced in the inner loop.

This one is good. I've replaced the (IMO, not very strong) generators
example with it.

Cheers,
--

--
Andreas Fuchs, (http://|im:asf <at> |mailto:asf <at> )boinkor.net, antifuchs

_______________________________________________
iterate-devel site list
```