lazy comparison for equality ?

klusacek@atrey.karlin.mff.cuni.cz klusacek@atrey.karlin.mff.cuni.cz
Wed, 24 Apr 2002 21:43:16 +0200


Hi -
I'm a Haskell beginner and I have a problem. 

Let's have a list which may be normal list
list1 = [1,2,3]
or a circular list
list2 = 1:2:list2

Now I'd like to have a function which tells me whether the 
given list is circular or not. This doesn't work:

circ l = l l
circ2 l [] = False
circ2 l (_:as) | l==as = True
               | True = (circ2 l as)


It seems that comparison l==as really compares element by element thus
falling into an infinite loop. I would need to compare pointers instead of
values.

Does anybody know how this could be done ?

Thanks.