reading integers from a stream



Hi Fabrizio,

I checked on ubuntu that openr handles paths case sensitive. 
parsetoken (which won't be in Maxima 5.14 anymore) uses the Lisp parser, so perhaps it is 
faster than parse_string. 
I hope the below code can help you.

Volker van Nek

/home/volker/Work/myFile.txt:
123 234 345 
456 567 678 
789 890 900

(%i1) stream: openr("/home/volker/Work/myFile.txt");
(%o1) #<INPUT BUFFERED FILE-STREAM CHARACTER /home/volker/Work/myFile.txt 
@1>
(%i2) while ( stringp( line: readline(stream) ) ) do (
listOfStrings: split(line),
listOfNumbers: if stringp(listOfStrings[1]) then map(parsetoken,listOfStrings) else [],
print(listOfNumbers) );
[123, 234, 345] 
[456, 567, 678] 
[789, 890, 900] 
[] 
(%o2)                                done
(%i3) close(stream);
(%o3)                                true



Am 20 Sep 2007 um 16:43 hat Fabrizio Caruso geschrieben:

> It seems to work in a non-case-sensitive way.
> 
> I am using Linux and the path has most of the times
> at leat one capital letter.
> 
> If I do this
> ?open(?"//home/caruso//Work//code//c++//ntl_server//lll_server//lll_server.fifo"),
> I get
> 
> nonexistent directory: #P"/home/caruso/work/"
> 
> Is there a solution?
> 
>    Fabrizio
> 
> 
> On Thu, 20 Sep 2007, Richard Fateman wrote:
> 
> >
> >
> >> -----Original Message-----
> > RJF:
> >> You may be able to read integers separated by new lines or by
> >> spaces by
> >> using lisp.
> >> Try foo:?open(filename);
> >>  ?read(foo); ?read(foo); ....
> >> Getting the filename in the right form, as a string, may be tricky.
> >> RJF
> >>
> > Hint  ...  Try   foo:?open(?"c:\\temp\\numbers")    for example.
> >
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima