new$List calls Lisp function directly, instead of repeatedly
calling "concat".

This change and the previous map! change probably
should go into IndexedList, but I really think we should
remove IndexedList :

1. It's not used anywhere beside List. (And probably
nobody uses it.)
2. Unlike arrays, index (elt) is O(n) for lists, so for performance
reasons, nobody should use index in loops, they should
use "rest".

diff --git a/src/algebra/list.spad b/src/algebra/list.spad
index dcebdb2..e53b314 100644
--- a/src/algebra/list.spad
+++ b/src/algebra/list.spad
@@ -250,6 +250,7 @@

  Implementation ==>
    IndexedList(S, LISTMININDEX) add
+      new(n, e) == MAKELIST(n, e)$Lisp
       nil()                    == empty()
       null l                   == empty?(l)
       cons(s, l)               == concat(s, l)
diff --git a/src/lisp/primitives.lisp b/src/lisp/primitives.lisp
index 6cc8c84..bea6a6f 100644
--- a/src/lisp/primitives.lisp
+++ b/src/lisp/primitives.lisp
@@ -49,6 +49,10 @@
 (defmacro ANCOLS (v)
     `(array-dimension (the (simple-array T (* *)) ,v) 1))

+;;; list creation
+(defun MAKELIST (size init)
+    (make-list size :initial-element init))
 ;;; string accessors

 (defmacro STR_ELT(s i)

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 post to this group, send email to
Visit this group at
For more options, visit

Reply via email to