Thank you all for the help.

If I understand correctly, you have presented various parsers to convert a 
character string into numbers.

Then, my next task is to read the text file word by word.

My example above is a short string of blank-separated numbers. In reality, 
however, my file contains a huge number of numbers separated by blanks, tabs, 
or newlines, or any mixture of these.

Because my files can be very large, I can't simply separate parsing from 
reading.

So, I imagine that this kind of code would be what I would write:

> var nums = newSeq[float](initialsize) # open file
> 
> while f.readWord(buf):
>     nums.add(buf.atof) # convert string to float

The system module has readLine but not readWord . . .

I remember writing an equivalent of readWord in pure C decades ago by reading 
one character at a time. Is this what you have to do in Nim ? I hope there is a 
convenient function like readLine but for words.

Reply via email to