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

From: Hari Prashanth K R (krhari at ccs.neu.edu)
Date: Sun Nov 8 05:12:25 EST 2009

Thanks Laurent... Thanks Jos it helped...

----- Original Message -----
From: "Laurent" <laurent.orseau at gmail.com>
To: "Jos Koot" <jos.koot at telefonica.net>
Cc: krhari at ccs.neu.edu, "plt-scheme" <plt-scheme at list.cs.brown.edu>
Sent: Sunday, November 8, 2009 4:24:57 AM GMT -05:00 US/Canada Eastern
Subject: Re: [plt-scheme] How to get tokenize a string?

that is simpler, indeed :) 


On Sun, Nov 8, 2009 at 10:02, Jos Koot < jos.koot at telefonica.net > wrote: 


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. 

Jos 

----- 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 



_________________________________________________ 
For list-related administrative tasks: 
http://list.cs.brown.edu/mailman/listinfo/plt-scheme 



Posted on the users mailing list.