[plt-scheme] list building?

From: John Clements (clements at brinckerhoff.org)
Date: Wed May 4 13:06:17 EDT 2005

On May 4, 2005, at 9:43 AM, Mike wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> How is this handled? Read all lines (sexps in this case)
> from a file, put the items in a list, then in another
> (define) process the list.
>
> When you read the file do you do this:
>
> (define (load-tasks fp)
>   (let ((task (read fp)))
>     (if (eq? task eof)
>       '()
>       (list task (load-tasks fp)))))
>
> so that at the end of the reading the resulting
> list looks like '((task1) (task2) ())?

Aside from anything else, you almost certainly want to use 'cons' 
instead of 'list' in the else clause above.  Remember:  (list a b) is 
just shorthand for (cons a (cons b `()).

HTH,

John Clements

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2430 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20050504/b8f0c85c/attachment.p7s>

Posted on the users mailing list.