Advertisement
4da

shen read from text file

4da
Dec 13th, 2011
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.64 KB | None | 0 0
  1. \* read a string from stream (EOF and #10 are delimitters) *\
  2. (define read-string-from-file
  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)))))
  8.  
  9. \* read list of strings from stream *\
  10. (define read-text-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
  19.   {string --> (list string)}
  20.   Path -> (read-text-stream (open file Path in)))
  21.  
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement