Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

There will be big changes for you but you will be happy.


comp / comp.lang.lisp / Re: another simple defmacro question

SubjectAuthor
o Re: another simple defmacro questionB. Pym

1
Subject: Re: another simple defmacro question
From: B. Pym
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Thu, 12 Sep 2024 04:57 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: another simple defmacro question
Date: Thu, 12 Sep 2024 04:57:08 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <vbtsau$3881$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Thu, 12 Sep 2024 06:57:08 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="15295cbec5a95e756a39a07bb6746ed8";
logging-data="106753"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19CeL5wGCdXUF+O4aoe0iHW"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:RA9buLbQyzhtyt4kZzvJAbwMZUc=
View all headers

Thomas A. Russ wrote:

> Not at all connected with your original problem, but you can
> exploit the full power of LOOP to greatly simplify this part
> of the code:
>
> > (let ((stringlist)
> > (tmpstr))
> > (with-open-file (infile fname :direction :input)
> > (loop
> > (setq tmpstr (read-line infile nil nil))
> > (unless tmpstr
> > (return))
> > (push tmpstr stringlist)
> > ))
> > (setq stringlist (nreverse stringlist))
> > stringlist
> > ))
>
> It can be transformed into:
>
> (with-open-file (infile fname :direction :input)
> (loop for tmpstr = (read-line infile nil nil)
> while tmpstr
> collect tmpstr))

It's somewhat shorter in Gauche Scheme.

(call-with-input-file "output.dat" port->string-list)

1

rocksolid light 0.9.8
clearnet tor