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

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

Path: ...!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: 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=
Bytes: 1497

> 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