On Mon, Sep 1, 2008 at 11:42 AM, Mov GP 0 wrote:

> I'm new to axiom and tried to count the elements in a cyclic
> list and expected to get %PositiveInfiniy as Answer. Instead it
> resulted in an infinite loop. Version is Axiom 3.9 (September 2005)
>

Welcome.

You are using a rather old version of Axiom. Perhaps you should
upgrade to one of the newer version in the axiom family:

 Axiom:     http://www.axiom-developer.org/
 OpenAxiom: http://www.open-axiom.org/
 FriCAS:    http://fricas.sourceforge.net/

> =======================================
> What I've did:
>
> u:= [9,2,4,7]; concat! (u, [1,2,42]); end := rest(u,4); part :=
> rest(u,2);  setrest!(end, part);
>
> u is now [9,2,(42,7,1)] -- the () are the cyclic part
>
> when you count the elements using "#u" then it resolves in a loop.
>

I can confirm that this works in FriCAS:

                 FriCAS (AXIOM fork) Computer Algebra System
                         Version: FriCAS 2008-02-09
               Timestamp: Thursday March 27, 2008 at 18:27:30
-----------------------------------------------------------------------------
   Issue )copyright to view copyright notices.
   Issue )summary for a summary of useful system commands.
   Issue )quit to leave FriCAS and return to shell.
-----------------------------------------------------------------------------

(1) -> u:= [9,2,4,7]; concat! (u, [1,2,42]); end := rest(u,4); part
:=rest(u,2);  setrest!(end, part);

                                          Type: List PositiveInteger
(2) -> u
             _____
   (2)  [9,2,4,7,1]
                                          Type: List PositiveInteger
(3) -> #u

   >> System error:

LENGTH: A proper list must not be circular: #1=(9 2 . #2=(4 7 1 . #2#))


> =======================================
> What I 've expected:
>
> There should be a Property like "isCyclic?" that tests if the list
> is cyclic.

There is an operator. Browse the List constructor in hyperdoc. Look
for 'cyclic?'.

(3) -> cyclic? u

   (3)  true
                                          Type: Boolean

> The new code for counting should be something like
>
> count(x) == if isCyclic? x then return ?PositiveInfinity else #x
>

(4) -> count(x) == if cyclic? x then return %PositiveInfinity else #x
                                          Type: Void
(
5) -> count u
   Compiling function count with type List PositiveInteger ->
      Polynomial Integer

   (5)  %PositiveInfinity
                                          Type: Polynomial Integer


> =======================================
> Question:
> Is this fixed already in a newer version?
>

If this doesn't work in other forks of Axiom then it should be
reported as an error.

Regards,
Bill Page.


_______________________________________________
Axiom-developer mailing list
Axiom-developer@nongnu.org
http://lists.nongnu.org/mailman/listinfo/axiom-developer

Reply via email to