Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!mcnc!ece-csc!uvacs!mac
From: mac@uvacs.CS.VIRGINIA.EDU (Alex Colvin)
Newsgroups: comp.lang.lisp
Subject: Re: cdr encoding (was Re: Importance of REPLACA, REPLACD)
Message-ID: <1792@uvacs.CS.VIRGINIA.EDU>
Date: Mon, 20-Jul-87 15:05:16 EDT
Article-I.D.: uvacs.1792
Posted: Mon Jul 20 15:05:16 1987
Date-Received: Wed, 22-Jul-87 04:27:11 EDT
References: <22@citcom.UUCP> <6900008@iaoobelix.UUCP> <19747@ucbvax.BERKELEY.EDU> <8052@labrea.STANFORD.EDU>
Organization: University of Virginia
Lines: 64
Summary: cyclic list structures

There are uses for infinite (cyclic) list structures.  Many of these
can be constructed by something like a set of simultaneous recursive
equations (see [1,2]), in much the same way that LABELS defines a set
of mutually recursive functions.

For example, an infinite list of 'T is

(LABELS ( (lotsa-t (cons T lotsa-t))
          )
	...don't try to print it
        )


             +------+
lotsa-t --+->| T | ----+
          |  +------+  |
          +------------+

a somewhat more tangled version
(LABELS ( (a (list b c))
          (b (list c a))
          (c (list a b))
          )
        ...
        )


    +------------------+
    |                  |
    |  +---+    +---+  |
a --+->|+|+---->|+|/|  |
       +|--+    +|--+  |
        |        |     |
    +---|--------+     |
    |   v              |
    |  +---+    +---+  |
b +-|->|+|+---->|+|/|  |
  | |  +|--+    +|--+  |
  +-|---|----+   +-----+
    |   |    |         |
    |   v    +---+     |
    |  +---+    +|--+  |
c --+->|+|+---->|+|/|  |
       +|--+    +---+  |
        |              |
        +--------------+

You get the idea that these definitions are easier to follow than any
chain of RPLACs.
In particular, what you expect of (labels ((c (list a b)) remains true.

[1]
P. J. Landin.
"A Correspondence between ALGOL 60 and Church's Lambda-Notation: Part I"
Comm. ACM 8(2), February 1965.
Defines LET REC as a mutually recursive LET.

[2]
Morris & Schwarz.  "Computing Cyclic List Structures". Proc. 1980 LISP
Conference.
Shows how to apply this to mutually recursive lists.

What's nice is that the same implementation will work for both data and
function recursion.