Deutsch   English   Français   Italiano  
<vbr6je$3efqg$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: "B. Pym" <Nobody447095@here-nor-there.org>
Newsgroups: comp.lang.lisp,comp.lang.scheme
Subject: Re: CL idioms
Date: Wed, 11 Sep 2024 04:33:54 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <vbr6je$3efqg$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Wed, 11 Sep 2024 06:33:55 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3be87affaab0b87468eb137bb3ffc6ef";
	logging-data="3620688"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19womoFcw0Tc/n9j0+79nU4"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:jkoBT7ggY3jEp2YfHEYPWqFCBho=
Bytes: 1780

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 gauche.generator)

(generator->vector (file->generator "output.dat" read-line))