3
$\begingroup$

I'm reading the introduction to Godel, Escher, Bach and and there's heavy discussion of mathematical sets which contain themselves. Being a far better programmer than mathematician, I put it into terms I'm more comfortable with and started to think about arrays which contain/reference themselves.

I know that recursion is a very powerful concept in CS but that it's typically manifested through functions which call themselves. I see recursive functions in algorithms all the time, but I've never before run across an array that has itself as an element. I was just wondering if there's any particular "usefulness" or practical application for arrays which contain themselves (as there is for functions which call themselves).

$\endgroup$
4
$\begingroup$

If you represent a (directed) graph in an adjacency "list" representation, i.e. each node has an array of (pointers to) its immediate successors, then any cyclic graph would arguably be an example of an array that "contains" (really references) itself. In practice, the "object graph" of references between the objects in a program will often be an example of this albeit not quite so cleanly

Indeed, for non-well-founded set theories with an anti-foundation axioms stating that sets can contain themselves, cyclic graph models are quite natural.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.