William James
7/26/2015 6:44:00 PM
Marco Antoniotti wrote:
> > (defun file-to-lists (input-file-name)
> > "reads a test file: return a list of lines, ie a sublist of string
> > tokens"
> > (with-open-file (stream (make-pathname :name input-file-name)
> > :direction :input)
> > (let ((acc (list)))
> > (do* ((current-line (read-line stream nil 'eof)
> > (read-line stream nil 'eof))) ;current line of
> > the stream
> > ((equal current-line 'eof) (nreverse acc))
> > (push (str-tokenize current-line) acc)))))
> >
>
> Standard reply (untested)
>
> (defun file-to-list (ifn)
> (with-open-file (stream ifn :direction :input)
> (loop for line of-type (or null string) = (read-line stream nil nil)
> while line
> collect (str-tokenize line))))
Note that there is no "str-tokenize" in CL (COBOL-Like).
Gauche Scheme:
(use srfi-13 :only (string-tokenize))
(define (file-to-list filename)
(with-input-from-file filename
(cut generator-map
(cut string-tokenize <>)
read-line)))
--
Arrogant and isolated, the elite treat the ordinary citizens of the empire as
slaves and potential enemies.
www.kolumbus.fi/aquilon/america-middle-class-and-the-end-of-growth.htm