[plt-scheme] sicp exercise 2.23

From: Arthur Nunes-Harwit (anh at cs.rit.edu)
Date: Wed Apr 30 09:17:06 EDT 2008

On Tue, 29 Apr 2008, Doug Orleans wrote:

> I'm guessing this is not the solution they had in mind:
> (define (for-each proc items)
>  (map proc items)
>  true)

   My impression is that the order of evaluation for map is not specified, 
so this implementation is not guaranteed to work.  For example, consider 
the following implementation of map.

(define (map proc items)
   (mapa proc (reverse items) '()))

(define (mapa proc items a)
   (if (null? items)
       (mapa proc (cdr items) (cons (proc (car items)) a))))


Posted on the users mailing list.