[plt-scheme] How to get tokenize a string?

From: Jos Koot (jos.koot at telefonica.net)
Date: Sun Nov 8 04:02:26 EST 2009

Why not using just read? For the first read you would find:
(read port) --> 2.5500000e-002
If your file contains numers only:

; read a file containing numbers and return the list of these numbers.
(define (read-file-of-numbers port) ; unchecked code!
 (let ((item (read port)))
  (if (eof-object item) '( )
   (cons item (read-file-of-numbers port)))))

In fact the above routine can be used for any file that contains a sequence of sexprs and would return a list of the sexprs.


----- Original Message ----- 
From: <krhari at ccs.neu.edu>
To: "plt-scheme" <plt-scheme at list.cs.brown.edu>
Sent: Sunday, November 08, 2009 8:41 AM
Subject: [plt-scheme] How to get tokenize a string?

> Hi,
> I have a file which contains data like this
>  2.5500000e-002  3.6238983e-002
>  2.5500000e-002  3.6238638e-002
>  2.5500000e-002  3.6237603e-002
> ...
> I am working on a small animation I need these numbers to calculate some things there... I am using 2htdp/universe teachpack...
> I actually found string->tokenize function in SRFI doc... Can I use it? If yes can anyone guide me how to use SRFI? If no is there 
> any other way out other than converting the file into a string then using sting->list and doing it in brute force way?
> If I use file->string, I get a string like this
> "  2.5500000e-002  3.6238983e-002\r\n  2.5500000e-002  3.6238638e-002\r\n  2.5500000e-002  3.6237603e-002\r\n"
> Please help me out...
> Thanks
> Hari
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.