[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: CL idioms

William James

8/23/2015 11:41:00 AM

Pascal Costanza wrote:

> > In Scheme I would probably do something like (list->vector (reverse
> > dict)) but is there a way to build the vector directly without knowing
> > the size in advance? Or is there a more "CL" way to do this?
>
> What about this:
>
> (with-open-file (str filename :direction :input)
> (loop for line = (read-line str nil 'eof)
> until (eql line 'eof)
> collect line into dict
> finally (return (apply #'vector dict))))
>
> or:
>
> (with-open-file (str filename :direction :input)
> (loop for line = (read-line str nil 'eof)
> until (eql line 'eof)
> count t into line-count
> collect line into dict
> finally (return
> (make-array line-count :initial-contents dict))))

Gauche Scheme:

(use file.util :only (file->string-list))

(list->vector (file->string-list filename))

--
Under the disguise of liberalism, humanism, and democracy, Europeans have been
persuaded to commit racial suicide -- a race that has achieved so much and has
survived so much has been tricked into welcoming its own downfall and to take
active measures in order to become a stranger on its own soil.
www.kolumbus.fi/aquilon/moscowspeech2010.htm