The 'construct' and 'numberOfComputedEntries' for Stream
is recursive, thus it can easily stack overflow, for example:

ls := new(10^5,1)$List INT;
ss := construct(ls)$Stream INT
numberOfComputedEntries ss

Patch:

--- a/src/algebra/stream.spad
+++ b/src/algebra/stream.spad
@@ -192,8 +192,13 @@
 --% CNAGG functions

   construct l ==
-    empty? l => empty()
-    concat(first l, construct rest l)
+      empty? l => empty()
+      l := reverse l
+      res := empty()
+      while not empty? l repeat
+          res := concat(first l, res)
+          l := rest l
+      res

   --entries x ==
     -- returns a list of the stream elements
@@ -765,10 +770,7 @@

 --% CNAGG functions

-    construct l ==
-      -- copied from defaults to avoid loading defaults
-      empty? l => empty()
-      concat(first l, construct rest l)
+    construct l == APPEND(l, empty())$Lisp

 --% ELTAGG functions

@@ -1049,8 +1051,11 @@
       not explicitlyEmpty? x and not lazy? x

     numberOfComputedEntries x ==
-      explicitEntries? x => numberOfComputedEntries(rst x) + 1
-      0
+        count := 0
+        while explicitEntries? x repeat
+            count := count + 1
+            x := rst x
+        count

     setrestt!(x, n, y) ==
       n = 0 => setrst!(x, y)

-- 
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.

Reply via email to