I don't think you can write such a function.  For instance, how would you
know whether [1..] is circular or not?  In order to know that it's not
you'd need to evaluate it fully.

--
Hal Daume III

 "Computer science is no more about computers    | [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

On Wed, 24 Apr 2002 [EMAIL PROTECTED] wrote:

> 
> 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.
> 
> 
> 
> 
> 
> _______________________________________________
> Haskell-Cafe mailing list
> [EMAIL PROTECTED]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to