SHOW:
|
|
- or go back to the newest paste.
| 1 | \* read a string from stream (EOF and #10 are delimitters) *\ | |
| 2 | - | (define read-string-from-file |
| 2 | + | (define read-string |
| 3 | {(stream in)--> string}
| |
| 4 | Stream -> (let Byte (read-byte Stream) | |
| 5 | (if (or (= Byte -1) (= Byte 10)) | |
| 6 | "" | |
| 7 | - | (cn (byte->string Byte) (read-string-from-file Stream))))) |
| 7 | + | (cn (n->string Byte) (read-string-from-file Stream))))) |
| 8 | ||
| 9 | \* read list of strings from stream *\ | |
| 10 | - | (define read-text-stream |
| 10 | + | (define read-strings-from-stream |
| 11 | {(stream in) --> (list string)}
| |
| 12 | Stream -> (let Str (read-string-from-file Stream) | |
| 13 | (if (= Str "") | |
| 14 | [] | |
| 15 | [ Str | (read-text-stream Stream) ]))) | |
| 16 | ||
| 17 | \* read list of strings from file *\ | |
| 18 | - | (define read-txt-file |
| 18 | + | (define read-text-file |
| 19 | {string --> (list string)}
| |
| 20 | - | Path -> (read-text-stream (open file Path in))) |
| 20 | + | Path -> (read-strings-from-stream (open file Path in))) |