From: Ken A. <kan...@bb...> - 2003-06-25 20:33:31
|
Try something like this: (load "elf/basic.scm") (define data (map* (lambda (line) (string->expr (string-append "(20" (.substring line 1)))) (java.io.BufferedReader. (java.io.FileReader. "d:/temp/geof.data")))) At 03:51 PM 6/25/2003 -0400, Geoffrey Knauth wrote: >I have some code which reads a bunch of data in sexps: > >(yymmdd blah blah blah ...) >(yymmdd blah blah blah ...) >(yymmdd blah blah blah ...) > >I can read all of them with this JScheme code: > >(load "elf/load.scm") >(define in (openInputPort "foo")) >(define entries (eval (read in))) >(.close in) > >if I first process the file with this Perl script: > >print "'(\n"; >while (<>) { > chomp $_; > $_ =~ s/^\(03/\(2003/; # so that yymmdd won't be interpreted by JScheme as octal > print "$_\n"; >} >print ")\n"; > >which puts '( and ) around the entire contents of the original file. > >Is there a way to do the whole thing in JScheme and get rid of the Perl pre-processing script? > >I can handle the regexp substitution. What I was having trouble doing was using eval and read to ingest the data that lacked the surrounding '( and ). > >Geoffrey >-- >Geoffrey S. Knauth | http://knauth.org/gsk > > > >------------------------------------------------------- >This SF.Net email is sponsored by: INetU >Attention Web Developers & Consultants: Become An INetU Hosting Partner. >Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! >INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php >_______________________________________________ >Jscheme-user mailing list >Jsc...@li... >https://lists.sourceforge.net/lists/listinfo/jscheme-user |