We already have 'concat : List % -> %', and it's equally useful to have its destructive counterpart, for long lists, this version can save many many copies.
Although 'concat : List % -> %' is exported in LNAGG, I believe that the proper place for 'concat/concat! : List % -> %' should be in URAGG. -- 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 fricas-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/CAGBJN93_s5Czp2q4htm45FuawwDxZLrWRtVJb6k--xJ0%2BRCX9g%40mail.gmail.com.
diff --git a/src/algebra/aggcat.spad b/src/algebra/aggcat.spad index 23a785db..73678bf7 100644 --- a/src/algebra/aggcat.spad +++ b/src/algebra/aggcat.spad @@ -1381,6 +1381,12 @@ UnaryRecursiveAggregate(S : Type) : Category == Join(RecursiveAggregate S, concat! : (%, S) -> % ++ concat!(u, x) destructively adds element x to the end of u. ++ Note: \spad{concat!(a, x) = concat!(a, [x])}. + concat! : List % -> % + ++ concat!(lu), where \spad{lu} is a list of aggregates + ++ \spad{[a, b, ..., c]}, returns a single aggregate consisting + ++ of the elements of \spad{a} followed by those of \spad{b} + ++ followed ... by the elements of \spad{c}. This function may + ++ destructively modify the aggregates in \spad{lu}. cycleSplit! : % -> % ++ cycleSplit!(u) splits the aggregate by dropping off the cycle. ++ The value returned is the cycle entry, or empty() if none exists. @@ -1635,6 +1641,15 @@ UnaryRecursiveAggregate(S : Type) : Category == Join(RecursiveAggregate S, setelt!(x, "rest", a) == setrest!(x, a) concat(x : %, y : %) == concat!(copy x, y) + concat!(lu : List %) == + empty? lu => empty() + res := first lu + t := tail res + for u in rest lu repeat + setrest!(t, u) + t := tail t + res + -- The qxxx variants are for speed. If we do not care about -- speed the regular ones will do.