> < ^ Date: Fri, 05 Mar 1999 17:41:36 +0000 (GMT)
> < ^ From: Alexander Hulpke <hulpke@math.colostate.edu >
> < ^ Subject: Re: problems with lists

Dear GAP-Forum,

Roberto Radina wrote:

> I'm using recursively defined lists, i.e. objects of this kind:
> gap> a:=[];; b:=[a];; a[1]:=b;;
> I found that the basic operations don't work with these lists. For example:
> gap> a=b;
> causes to run out of memory.
> Is my usage of lists supported or it must be considered bad usage

The GAP language permits the creation of recursive structures.

Normally such recursive structures will arise only if two objects refer to
each other (for example a group pointing to its derived subgroup and the
derived subgroup pointing back to its parent) . In this situation comparison
will not have to refer to the recursive part and thus the error you observed
will not arise.

However the comparison for lists which is used by GAP (two lists are equal
if and only if its elements are equal) cannot be guarantee to
test recursive objects of the kind you created for equality.
I have to regret that your example -- while syntactically perfectly
correct -- goes beyond the capabilities of GAP.
(I must admit that I'm not even sure whether in your example `a' is equal to
`b' -- either answer seems to be consistent. Therefore I can not even
imagine an algorithm that would answer your question.)

You might consider this to be an unfixed error and our only excuse for this
is that we are only human.

The only advice I can give you for your concrete problem is either not to
use equality comparison (Probably an `IsIdenticalObj' which only compares
the pointers to the top level lists is sufficient for your purpose?) or to
make the recursion indirect via indices (coding the equality test

I think that if recursion is to be allowed then the function '=' must at
least report the problem and not cause exiting, wasting all the work made.

I agree that it would be desirable to have GAP report an error message
than simply exiting. Not knowing how much work this would involve to
implement (and whether it would come with a performance cost for
``ordinary'' list comparisons) however I'm reluctant to promise that such a
test will be implemented in future versions.

We will however add a warning to the manual that equality comparison of
recursive lists may lead to problems.

Best regards,

Alexander Hulpke

Miles-Receive-Header: reply

> < [top]