login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for #432 List doesn't check for circularity in length revision 4 of 6

1 2 3 4 5 6
Editor: Bill Page
Time: 2008/09/01 12:43:33 GMT-7
Note: speed

added:

From BillPage Mon Sep 1 12:42:34 -0700 2008
From: Bill Page
Date: Mon, 01 Sep 2008 12:42:34 -0700
Subject: speed
Message-ID: <20080901124234-0700@axiom-wiki.newsynthesis.org>

Using FriCAS built with GCL-2.6.8pre the difference between
'LENGTH' and 'LIST-LENGTH' seems to be negligible. Usingclisp,
'LIST-LENGTH' actually seems a little faster.
\begin{axiom}
w:=[random(2^31)$INT for i in 1..10^5];
)set message time on
\end{axiom}
\begin{axiom}
for i in 1..10000 repeat integer(LENGTH(w)$Lisp)
\end{axiom}
\begin{axiom}
for i in 1..10000 repeat integer(LIST_-LENGTH(w)$Lisp)
\end{axiom}

Submitted by : kratt6 at: 2008-09-01T12:05:02-07:00 (15 years ago)
Name :
Axiom Version :
Category : Severity : Status :
Optional subject :  
Optional comment :

axiom
u:= [9,2,4,7]; concat! (u, [1,2,42]); end := rest(u,4); part:=rest(u,2);
setrest!(end, part);
Type: List PositiveInteger?

Asking for the number of elements of u will exhibit lisp-implementation-dependend behaviour, ranging from an error to an infinite loop.

We should either fix the documentation (saying, that this is the case), or check for circularity. This could be done by calling LIST_-LENGTH instead of LENGTH in ILIST, for example.

According to the common lisp standard list-length returns nil if the list is circular.

http://www.lispworks.com/documentation/HyperSpec/Body/f_list_l.htm

re: documentation --Bill Page, Mon, 01 Sep 2008 12:23:09 -0700 reply
On Mon, Sep 1, 2008 at 4:27 PM, Tim Daly wrote
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

Using FriCAS? built with GCL-2.6.8pre the difference between LENGTH and LIST-LENGTH seems to be negligible. Usingclisp, LIST-LENGTH actually seems a little faster.
axiom
w:=[random(2^31)$INT for i in 1..10^5];
Type: List Integer
axiom
)set message time on

axiom
for i in 1..10000 repeat integer(LENGTH(w)$Lisp)
Type: Void
axiom
Time: 27.42 (EV) + 0.01 (OT) + 0.09 (GC) = 27.52 sec

axiom
for i in 1..10000 repeat integer(LIST_-LENGTH(w)$Lisp)
Type: Void
axiom
Time: 28.52 (EV) = 28.52 sec