Please read what I said in the parent node.

That's not a proper list, so r5rs doesn't guarantee this will work. It does work with some scheme implementations, but MzScheme says

for-each: expects type <proper list> as 2nd argument, given: #0=(1 . # +0#); other arguments were: #<procedure:STDIN::59>
if I type this code in it.

Update: let me quote from the r5rs.

Pairs are used primarily to represent lists. A list can be defined recursively as either the empty list or a pair whose cdr is a list. More precisely, the set of lists is defined as the smallest set X such that

  • The empty list is in X.
  • If LIST is in X, then any pair whose cdr field contains LIST is also in X.
and later
library procedure: map proc list1 list2 ...,
The LISTs must be lists, and PROC must be a procedure taking as many arguments as there are lists and returning a single value. If more than one LIST is given, then they must all be the same length. `Map' applies PROC element-wise to the elements of the LISTs and returns a list of the results, in order. The dynamic order in which PROC is applied to the elements of the LISTs is unspecified.
library procedure: for-each proc list1 list2 ...,
The arguments to `for-each' are like the arguments to `map', but `for-each' calls PROC for its side effects rather than for its values. Unlike `map', `for-each' is guaranteed to call PROC on the elements of the LISTs in order from the first element(s) to the last, and the value returned by `for-each' is unspecified.

In reply to Re^5: If I was forced to use only one kind of loop for the rest of my days it would be a by ambrus
in thread If I was forced to use only one kind of loop for the rest of my days it would be a by collin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.