axiom-developer
[Top][All Lists]
Advanced

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

Re: [Axiom-developer] odd looping behavior


From: Camm Maguire
Subject: Re: [Axiom-developer] odd looping behavior
Date: Wed, 12 Oct 2011 12:12:59 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Greetings!  Sorry I did not see this earlier.  In case this is still
extant:

daly <address@hidden> writes:

> Camm,
>
> I am seeing some odd behavior in loops.
>
> If I write
>
> (let (result)
>   (setq a 
>     (do ((x somelist (cdr x)) (result nil))
>         ((atom x) (reverse result))
>       (setq result (cons (fn x) result)))))

This passes each cons of somelist to fn, not just the cars.  The outer
result binding is shadowed by the equivalent binding in the do.

>
> or, in a simple form as
> (let (result)
>   (setq a
>    (dolist (x somelist (nreverse result))
>      (setq result (cons (fn x) result)))))
>

This passes the each car of somelist to fn, and will give different
results thereby.

> I do not get the same behavior as
> (setq a 
>  (prog ()
>   (return
>    (do ((x somelist (cdr x)) (result nil))
>        ((atom x) (reverse result))
>     (setq result (cons (fn x) result))))))
>

This is equivalent to the first.

Please let me know if this does not clear this up, and/or if you find
different behavior w.r.t. any other lisp.

Take care,
-- 
Camm Maguire                                        address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah



reply via email to

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