Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #34: (l)user error


comp / comp.lang.scheme / Re: CL idioms

SubjectAuthor
o Re: CL idiomsB. Pym

1
Subject: Re: CL idioms
From: B. Pym
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Wed, 11 Sep 2024 04:33 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
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=
View all headers

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))

1

rocksolid light 0.9.8
clearnet tor