> I do not think making List non-cyclic is feasible. Namely
> once you allow in-place modification you can create
> cyclic structures. Testing that modification does not
> create cycles is prohibitivy expensive (after all we
> use in-place modification mostly in cases when we care
> about speed). Also, if you create new domain for
> cyclic lists there will be trouble sharing code with
> default case.
What I meant that make List "non-cyclic" is not doing
checkings so that no cyclic structure will be generated.
But we explicitly state that functions from domain List
will assume their arguments are non-cyclic. If users pass
a cyclic list to a List function, they are at their own risk.
Currently we only support cyclic list printing in List.
Other functions like 'copy', 'map' give error for cyclic
list. So current status is what I meant, only to say
in documentation that we don't support cyclic list,
and remove those detection for cycles, so instead
of error, one may get infinite loop, just like '='.
On the other hand, I examined many usage of
'setrest!', 'qsetrest!' and 'concat!', I found there is
only 1 place that generates cyclic list, in intfact.spad:
concat!(l, rest(l, 3))
Then only loops over 'l', no other operations.
I don't think there will be code sharing problems, we
will make aggregate non-cyclic by default, and put
cyclic functions in the section "if % has CyclicAggregate".
> Consider for example Streams: they use possibly cyclic
> lists as representation. Having two separate functions
> which create streams from lists (one from cyclic, the
> other from non-cyclic list) looks clumsy.
Cyclic stream is just cyclic list. I wonder if it's possible to
make stream non cyclic. There are many usage of 'repeating',
I need more investigation.
Even if we decide that Stream has CyclicAggregate, there
are no problems, since List adn CyclicList will have same
Rep (lisp list), we can call proper functions inside Stream.
In the comments of stream.spad:
Stream(S : Type) : Exports == Implementation where
-- problems:
-- 1) dealing with functions which basically want a finite structure
-- 2) 'map' doesn't deal with cycles very well
On the other hand, we can have proper '=' for cyclic list, but
not for stream.
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.