Programmer's conundrums

Sean 'Captain Napalm' Conner spc at
Mon Apr 3 13:43:36 CDT 2006

It was thus said that the Great der Mouse once stated:
> > Gee, I think I could do that in one memory location---cache the value
> > of the first pointer.  Keep following the list, checking each address
> > against the cached value.  If you hit 0, it terminates, otherwise if
> > the address matches the cached value, you have a loop.
> That works only if the place you start from is part of the loop.  If
> there is a non-loopy part which runs into a loop, your algorithm will
> compute forever when started in the non-loopy part.
> Consider A->B->C->D->E->C, started at A.

  Hmm ... good point.  

  -spc (But who constructs circular lists like that? 8-P

More information about the cctalk mailing list