Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Write yourself a threatening letter and pen a defiant reply.


comp / comp.lang.lisp / Re: need help w/ `loop'

SubjectAuthor
o Re: need help w/ `loop'B. Pym

1
Subject: Re: need help w/ `loop'
From: B. Pym
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Thu, 19 Sep 2024 07:13 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: need help w/ `loop'
Date: Thu, 19 Sep 2024 07:13:29 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <vcgiun$fueu$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Thu, 19 Sep 2024 09:13:29 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="771b02138d80f549ec3d77beeedbe017";
logging-data="522718"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/eHenpoXUwpcTfzbQfcvpf"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:KksSlarmL+lg1fVuJsgAndjuQTA=
View all headers

> This baffles me:
>
> (loop for i from 0 to 3
> with result = 0
> do
> (incf result i)
> return result)
>
> ==> 0
>
> Why? doesn't the stuff that occurs in the body of the `loop' make a
> difference? What am I missing?

Why didn't you do it this way?

(let ((result 0))
(loop for i from 0 to 3
do (incf result i))
result)

Why does it make worshippers of CL (COBOL-Like) so happy to do
everything inside of LOOP?

Why didn't you believe Paul Graham when he told you that LOOP
is a disaster?

Gauche Scheme:

(rlet1 result 0
(dotimes (i 4) (inc! result i)))

===>
6

1

rocksolid light 0.9.8
clearnet tor