Sujet : Re: another simple defmacro question
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp comp.lang.schemeDate : 12. Sep 2024, 06:57:08
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vbtsau$3881$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
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)