axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-developer] Counting Elements in Cyclic List


From: root
Subject: Re: [Axiom-developer] Counting Elements in Cyclic List
Date: Wed, 3 Sep 2008 14:38:00 -0400

>> In the documentation it states:
>>  "Note that using the "#" operator on a list with cycles
>>   causes Axiom to enter an infinte loop"
>>
>> See:
>> <http://axiom-developer.org/axiom-website/documentation.html>
>> in Volume 0: Axiom Jenks and Sutor p41
>>
>> Tim
>>
>

...[private reply snip]...


Consider the type information. Length takes a list and returns
a positive integer. 

"%PositiveInfinite" (actually %plusInfinity in Axiom) is not a
positive integer but a macro:


)d all

Properties of %plusInfinity
    This is a system-defined macro
    macro %plusInfinity () == plusInfinity()


so we see that %plusInfinity is a function call.

Next we notice the return type:


%plusInfinity
Type: OrderedCompletion Integer


so your new length would be a function defined as:

#(a:List):Union(PositiveInteger,OrderedCompletion Integer) ==
   ....
   plusInfinity()
   ....


which would impact a lot of algebra in a lot of ways.


The "more Axiom-like" solution to this problem, which I have been
looking at, would be to define a new domain called CircularList.
This new CircularList domain would export 

#(a:List):OrderedCompletion(Integer) ==
      plusInfinity()

and all of the operations that destructively modify a list such as
 
concat!(a:List,b:S):% ==

All of the destructive operations should be removed from List and
there should be a coerce from List to CircularList.

Thus you could freely use # on List objects (since they cannot be
circular). If you use concat! on a List object you get back a
CircularList object. If you use # on a CircularList object you get
back +infinity.

This is the correct fix. It will take time to do it right because
it needs
  (a) thinking
  (b) new code
  (c) changes to existing code
  (d) before-and-after unit tests
  (e) community feedback
  (f) regression tests
  (g) documentation changes

So your complaint is noted and a TODO task has been added to the queue.

Tim






reply via email to

[Prev in Thread] Current Thread [Next in Thread]