[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: Reading files

William James

5/20/2015 11:04:00 AM

Bernhard Pfahringer wrote:

> You might as well circumvent all these unexpected efficiency problems
> of vector-push-extend and adjusting arrays by simply collecting lines
> into a LIST and converting to a vector afterwards (if you really have to)
> by sticking to the original collecting version:
>
>
> (defun rfvr (file)
> (with-open-file (input file :direction :input)
> (coerce (loop for line = (read-line input nil nil)
> while line
> collect line)
> 'simple-vector)))

Gauche Scheme:

(define (rfvr file)
(list->vector
(with-input-from-file file
(lambda () (generator-map identity read-line)))))

--
The struggle of our time is to concentrate, not to dissipate: to renew our
association with traditional wisdom: to re-establish a vital connection between
the individual and the race. It is, in a word, a struggle against Liberalism.
--- T. S. Elliot