[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Do-loop enigma with two variables
From: |
Mike Gran |
Subject: |
Re: Do-loop enigma with two variables |
Date: |
Fri, 15 Jul 2016 18:50:11 +0000 (UTC) |
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)))