From: Geoffrey K. <ge...@kn...> - 2003-06-26 00:17:14
|
This worked perfectly on the first try, many thanks! --Geoffrey On Wednesday, Jun 25, 2003, at 16:33 US/Eastern, Ken Anderson wrote: > 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 |