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

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

Path: ...!npeer.as286.net!dummy01.as286.net!3.eu.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.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: When does ADJUST-ARRAY cons?
Date: Wed, 11 Sep 2024 03:54:51 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <vbr4aa$3e40s$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Wed, 11 Sep 2024 05:54:51 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f75513ee18371f2bf12b5336f2430a5a";
	logging-data="3608604"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18qP4RbsOTeMeJAmuaIVZXo"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:eOBNNzjLtp3212hRwWsjnK1UFq8=
Bytes: 1638

Edi Weitz wrote:

>   (defun foo ()
>     (with-open-file (strm "/tmp/test.big")
>       (loop as line = (read-line strm nil nil)
>             while line
>             summing (length line))))

Bad.  Very bad.  Fails to remove any carriage return
at the end of the line.  Consequently, the sum
may be incorrect.


Instead of CL, let's use a Lispy language.

Sum the lengths of all of the lines in a text file.
The length of a line is measured after removing the
end-of-line characters at the end.

Gauche Scheme

(use gauche.generator)

(define (foo f)
  (generator-fold
    +  0
    (gmap string-length (file->generator f read-line))))

(foo "output.dat")
  ===>
119