[plt-scheme] Teaching Scheme

From: Samuel Williams (space.ship.traveller at gmail.com)
Date: Mon May 3 11:51:10 EDT 2010

Dear Eli (& Sam),

I'm sorry that I missed that.

Thanks for taking the time to clarify it for me.

Its getting quite late (3AM) so I apologize for not being more cognitive.

I certainly appreciate the usefulness of returning a list vs printing it out. It is not a complex concept to understand. However, thanks for pointing this out.

Kind regards,
Samuel

On 4/05/2010, at 3:47 AM, Eli Barzilay wrote:

> On May  4, Samuel Williams wrote:
>> Dear Eli,
>> 
>> Thanks for your insightful response and the encoded examples.
>> 
>> I'm starting to get the feeling that it isn't possible to print to
>> stdout in Scheme? Is this the case?
> 
> No, you can use the `printf' function.  In the C-like version of my
> code, the last expression
> 
>    (for/list ([(door i) (in-indexed (in-vector doors))] #:when door)
>      (+ i 1))
> 
> collects the list of open doors -- and if you *really* want to make
> that part be identical to the C code too, use this instead:
> 
>    (for ([(door i) (in-indexed (in-vector doors))])
>      (printf "Door #~a is ~a.\n" (+ i 1) (if door "open" "closed" )))
> 
> But as several people said -- code that prints a list is much less
> useful than code that returns a list.
> 
> -- 
>          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>                    http://barzilay.org/                   Maze is Life!



Posted on the users mailing list.