[clean-list] Terminating strings
Pieter Koopman
pieter@cs.kun.nl
Wed, 05 Sep 2001 14:07:08 +0200
Hi,
At 12:14 05-09-2001 +0200, Siegfried Gonzi wrote:
>I have to deal with the following datas:
>
>12.34 12.34 54.33
>23.45 23.45 23.34
>56.3 133.3 00.443
>999
>34.55 23.34 232.34
>45.6 23.34 67.67
>
>And I want that the read process aborts at the line "999":
>
>CountLines:: !File -> !Int
>CountLines file = ReadLines 0 file
>where
> ReadLines:: !Int !File -> !Int
> ReadLines nLines file
> | line == "999" = abort("999 reached")
> #! (line,filerest) = sfreadline file
> = ReadLines (nLines + 1) filerest
>
>but it doesn't treminate. If I print out to the console the "line", then I get
>("999",65...). StdFile says that sfreadline also reads the newline
>delimiter. But I
>couldn't, in the complete Clean manuals, find the sign for the newline.
>Maybe I have to
>include this mark for my string comparison:
The newline character is '\n'. Your function works fine if you replace
"999" by "999\n".
Have fun,
Pieter Koopman