From: Javier
Subject: Mutually recursive lists
Date: 
Message-ID: <1155400564.879802.173560@m79g2000cwm.googlegroups.com>
I have a problem with this code:

(defparameter a (list 'a 'b 'c))
(defparameter b (list 'd 'e 'f))
(setf (first a) b)
(setf (first b) a)

This code halts at the last statment.
I know the reason (they are "mutually recursive" lists), but I wish to
know a similar code which works. That is, I want a reference in a to b,
and in b to a. I'd like it to be fast, too.

Thanks.

From: Barry Margolin
Subject: Re: Mutually recursive lists
Date: 
Message-ID: <barmar-39451D.13382612082006@comcast.dca.giganews.com>
In article <························@m79g2000cwm.googlegroups.com>,
 "Javier" <·······@gmail.com> wrote:

> I have a problem with this code:
> 
> (defparameter a (list 'a 'b 'c))
> (defparameter b (list 'd 'e 'f))
> (setf (first a) b)
> (setf (first b) a)
> 
> This code halts at the last statment.
> I know the reason (they are "mutually recursive" lists), but I wish to
> know a similar code which works. That is, I want a reference in a to b,
> and in b to a. I'd like it to be fast, too.
> 
> Thanks.

Set *PRINT-CIRCLE* to T.  Or don't try to print out the value after 
creating the loop, since it's infinitely long, e.g.

(progn (setf (first b) a)
  nil)

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Javier
Subject: Re: Mutually recursive lists
Date: 
Message-ID: <1155412143.276636.247590@75g2000cwc.googlegroups.com>
Barry Margolin wrote:
> Set *PRINT-CIRCLE* to T.  Or don't try to print out the value after
> creating the loop, since it's infinitely long, e.g.

Thank you, it does work.