Deutsch   English   Français   Italiano  
<v7m6hb$on7o$1@dont-email.me>

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

Path: ...!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
Subject: Re: Reading a text file not line by line but at once (beginner)
Date: Mon, 22 Jul 2024 17:57:00 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <v7m6hb$on7o$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Mon, 22 Jul 2024 19:57:00 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="9bd2863663604f2e05c19a8ebb644b33";
	logging-data="810232"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19XplvQySLSBzCRnGlvjUis"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:VPrPlt67kPsKcfqpvjqRa6xQK+U=
Bytes: 1747

> > I have a file which consists of one word per line and I would like to
> > read it into a single list.
> > Searching the web[1] I found something which I adapted to my
> > needs. Basically the code works but it is terribly inefficient. This
> > is not the fault of the CL Cookbook. Probably I am using a hammer as a
> > screwdriver.
> >
> > I'd be happy if you can give me some directions how I can tackle the
> > problem in a better way.
> 
> I like loop for this:
> 
> (with-open-file (s "foo.txt" :direction :input)
>   (loop for line = (read-line s nil)
>      while line
>      collect line))

Gauche Scheme

(use gauche.generator)

(with-input-from-file "temp.txt"
  (cut  generator->list read-line))


Paul Graham, May 2001:

A hacker's language is terse and hackable. Common Lisp is not.

The good news is, it's not Lisp that sucks, but Common Lisp.