guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Do-loop enigma with two variables


From: Vladimir Zhbanov
Subject: Re: Do-loop enigma with two variables
Date: Fri, 15 Jul 2016 22:36:59 +0300
User-agent: Mutt/1.5.23 (2014-03-12)

On Fri, Jul 15, 2016 at 06:50:11PM +0000, Mike Gran wrote:
> 
> On Friday, July 15, 2016 7:27 AM, Pierre Lairez <address@hidden> wrote:
> 
> >
> >
> >Dear guile users,
> >
> >When running the following loop:
> >(do ((i 1 (+ 1 i))
> >     (j 0 i))
> >    ((> i 4) (newline))
> >  (display (list i j)))
> >
> >I expect without hesitation to read
> >(1 0)(2 1)(3 2)(4 3)
> >
> >To my surprise, I obtain
> >(1 0)(2 2)(3 3)(4 4)
> 
> 
> Yeah, I get the same in 2.0.11
> 
> I don't know the correct terminology
> 
> The "i" in (j 0 i) is a reference to
> 
> the "i" that is bound (+ 1 i).
> 
> You can prove this by running the following
> 
> (do ((i 1 (+ 1 i)) (j 0 (+ i 0)))
>   ((> i 4) (newline))
>   (display (list i j)))
>

Yes, I used ,expand to see what's happening, and it seems that
named let is broken: if you replace i with (+ i 0) it uses `some
other i'.

-- 
  Vladimir



reply via email to

[Prev in Thread] Current Thread [Next in Thread]