I don't like the grammar that uses

    "func"/list1

to do

    reduce(func, list1)


First, this is a strange grammar.

Also I don't like to have special grammar to do things can
be done by normal grammar.

This patch replaces '"append"/' with normal function call
'concat : List % -> %', it's simpler and faster.

If you agree, I plan to replace other usage of '"func"/' by
normal function calls.

grep '"[a-zA-Z]*" */' *spad   shows 135 usage of such grammar,
only uses function max/min/setUnion/and/or/gcd/lcm.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/CAGBJN936cx4UgYvxjpdf97pmgsx0%3Djcidp4Pb7RCooOb%3DA6UHQ%40mail.gmail.com.
diff --git a/src/algebra/algfunc.spad b/src/algebra/algfunc.spad
index 89d80d30..625752f5 100644
--- a/src/algebra/algfunc.spad
+++ b/src/algebra/algfunc.spad
@@ -127,7 +127,7 @@ AlgebraicallyClosedField() : Category == Join(Field, RadicalCategory) with
           h := last decompList
           g := leftFactorIfCan(p, h) :: SUP
           groots := allroots(g, y, fn)
-          "append"/[allroots(h-r::SUP, y, fn) for r in groots]
+          concat [allroots(h-r::SUP, y, fn) for r in groots]
       ans := []$List(%)
       while not ground? p repeat
         alpha := assign(x := new(y)$Symbol, fn(p, x))
diff --git a/src/algebra/cycles.spad b/src/algebra/cycles.spad
index 0452fcd7..5759892e 100644
--- a/src/algebra/cycles.spad
+++ b/src/algebra/cycles.spad
@@ -119,8 +119,7 @@ CycleIndicators : Exports == Implementation where
     divisors : I -> L I
     divisors n ==
       b := factorList(n :: FR)
-      c := concat(1,"append"/
-                 [[a.factor^j for j in 1..a.exponent] for a in b])
+      c := concat(1, concat [[a.factor^j for j in 1..a.exponent] for a in b])
       if #(b) = 1 then c else concat(n, c)
 
     ss : (I, I) -> SPOL RN
diff --git a/src/algebra/cyldec.spad b/src/algebra/cyldec.spad
index 160f9b60..d11f67e5 100644
--- a/src/algebra/cyldec.spad
+++ b/src/algebra/cyldec.spad
@@ -155,7 +155,8 @@ SimpleCell(TheField, ThePols) : PUB == PRIV where
          lp1 := gcdBasis(lp)$PACK
          empty?(lp1) => [pointToCell(0, true, var)]
          b := ("max" / [ boundOfCauchy(p)$VARS for p in lp1])::TheField
-         l := "append" / [allRootsOf(makeSUP(unitCanonical(p))) for p in lp1]
+         l : List TheField :=
+             concat [allRootsOf(makeSUP(unitCanonical(p))) for p in lp1]
          l := sort(l)
          l1 := separate(l, -b, b)
          res : List(%) := [pointToCell(first(l1), true, var)]
diff --git a/src/algebra/galfact.spad b/src/algebra/galfact.spad
index 6d2761be..049e9634 100644
--- a/src/algebra/galfact.spad
+++ b/src/algebra/galfact.spad
@@ -775,7 +775,7 @@ GaloisGroupFactorizer(UP) : Exports == Implementation where
       lrf := cf::LR
       dh := degree(lrf.right)
       d1 := divideSet(d, dh)
-      "append"/[ henselfact(g(lrf.right), false,
+      concat [ henselfact(g(lrf.right), false,
                            sel_set(d, degree(g), dh)) for g in
          henselfact(lrf.left, true, d1) ]
 
diff --git a/src/algebra/gpgcd.spad b/src/algebra/gpgcd.spad
index 87d8c274..bf4ac1f2 100644
--- a/src/algebra/gpgcd.spad
+++ b/src/algebra/gpgcd.spad
@@ -245,7 +245,7 @@ GeneralPolynomialGcdPackage(E, OV, R, P) : C == T where
            lr := [ randomR() for vv in lv]
          ans
       variables(p1 : SUPP) ==
-        removeDuplicates ("concat"/[variables u for u in coefficients p1])
+        removeDuplicates concat [variables u for u in coefficients p1]
       gcdTrivial(p1 : SUPP, p2 : SUPP) ==
         -- p1 is non-zero, but has degree zero
         -- p2 is non-zero
diff --git a/src/algebra/moddfact.spad b/src/algebra/moddfact.spad
index ec371e80..94c26b37 100644
--- a/src/algebra/moddfact.spad
+++ b/src/algebra/moddfact.spad
@@ -114,7 +114,7 @@ ModularDistinctDegreeFactorizer(U) : C == T where
       [[(dd.factor)::U, dd.degree]$UDDRecord for dd in ans]$UDDList
 
     sepfact(factList) ==
-      "append"/[sepFact1(f) for f in factList]
+      concat [sepFact1(f) for f in factList]
 
     separateFactors(uddList, q) ==
       ans := sepfact [[reduce(udd.factor, q), udd.degree]$DDRecord for
diff --git a/src/algebra/multpoly.spad b/src/algebra/multpoly.spad
index 20d02c21..4755769e 100644
--- a/src/algebra/multpoly.spad
+++ b/src/algebra/multpoly.spad
@@ -524,7 +524,7 @@ SparseMultivariatePolynomial(R : Join(SemiRng, AbelianMonoid),
 
       coefficients p ==
         p case R => list(p :: R)$List(R)
-        "append"/[coefficients(p1)$% for p1 in coefficients(p.ts)]
+        concat [coefficients(p1)$% for p1 in coefficients(p.ts)]
 
       retract(p : %) : R ==
         p case R => p :: R
diff --git a/src/algebra/numsolve.spad b/src/algebra/numsolve.spad
index e6828a07..b195ba2b 100644
--- a/src/algebra/numsolve.spad
+++ b/src/algebra/numsolve.spad
@@ -316,8 +316,7 @@ InnerNumericFloatSolvePackage(K, F, Par) : Cat == Cap where
            if listGen ~= [] then
              listG : L L P K :=
                [[dmpToP(pf)$PolToPol(lv, K) for pf in pr] for pr in listGen]
-             result :=
-               "append"/[findGenZeros(res,rlv,eps) for res in listG]
+             result := concat [findGenZeros(res,rlv,eps) for res in listG]
              for gres in listGen repeat
                 partRes := delete(partRes, position(gres, partRes))
            -- adjust the non-generic components
diff --git a/src/algebra/solverad.spad b/src/algebra/solverad.spad
index 50fba034..b9b265c0 100644
--- a/src/algebra/solverad.spad
+++ b/src/algebra/solverad.spad
@@ -230,12 +230,12 @@ RadicalSolvePackage(R) : Cat == Capsule where
           listGen := [res for res in rpRes|isGeneric?(res, rlv)]
           result : L L RE := []
           if listGen ~= [] then
-            result := "append"/[findGenZeros(res,rlv) for res in listGen]
+            result := concat [findGenZeros(res,rlv) for res in listGen]
             for res in listGen repeat
                 rpRes := delete(rpRes, position(res, rpRes))
            --  non-generic components
           rpRes = [] => result
-          append("append"/[findZeros(res,rlv) for res in rpRes],
+          append(concat [findZeros(res,rlv) for res in rpRes],
                          result)
 
         radicalSolve(lp : L RF, lv : L SY) ==
diff --git a/src/algebra/transsolve.spad b/src/algebra/transsolve.spad
index 3a9c7141..00e6b491 100644
--- a/src/algebra/transsolve.spad
+++ b/src/algebra/transsolve.spad
@@ -150,7 +150,7 @@ TransSolvePackage(R) : Exports == Implementation where
               -- Type  :  Fraction SparseUnivariatePolynomial Expression R
           lfatt := factorList factorPolynomial(numer f
                                            )$ExpressionFactorPolynomial(R, RE)
-          lr:L RE := "append" /[zerosOf(fatt.factor,x) for fatt in lfatt]
+          lr : L RE := concat [zerosOf(fatt.factor,x) for fatt in lfatt]
               -- Type  :  List Expression R
           r1 := []::L RE
           for i in 1..#lr repeat
@@ -160,7 +160,7 @@ TransSolvePackage(R) : Exports == Implementation where
           if not testkernel(bigX_back, x) then
             if bigX = bigX_back then return []::L EQ RE
             return
-              "append"/[solve(bigX_back-ri, x) for ri in r1]
+              concat [solve(bigX_back-ri, x) for ri in r1]
           newlist := []::L EQ RE
 
           for i in 1..#r1 repeat
@@ -168,7 +168,7 @@ TransSolvePackage(R) : Exports == Implementation where
              f := univariate(elR, kernel(x))
               -- Type  :  Fraction SparseUnivariatePolynomial Expression R
              lfatt := factorList factorPolynomial numer f
-             secondsol := "append" /[zerosOf(ff.factor,x) for ff in lfatt]
+             secondsol : L RE := concat [zerosOf(ff.factor,x) for ff in lfatt]
              for j in 1..#secondsol repeat
                 newlist := cons((x::RE)=rootSimp( secondsol(j) ), newlist)
           newlist
@@ -517,7 +517,7 @@ TransSolvePackage(R) : Exports == Implementation where
         rlvar := reverse lvar
         sols : L L EQ RE := list(empty())
         for p in rplist for v in rlvar repeat
-           sols := "append"/[solve1Pol(p,v,sol) for sol in sols]
+           sols := concat [solve1Pol(p,v,sol) for sol in sols]
         sols
 
      frac_to_expr(q : Fraction(SparseMultivariatePolynomial(R, K))) : RE ==
@@ -567,9 +567,8 @@ TransSolvePackage(R) : Exports == Implementation where
         lfrac : L Fraction Polynomial RE :=
            [makeFracPoly(expr, lvar) for expr in lexpr]
         trianglist := triangularSystems(lfrac, lvar)
---        "append"/[solve1Sys(plist, lvar) for plist in trianglist]
         l : L L L EQ RE := [solve1Sys(plist, lvar) for plist in trianglist]
-        reduce(append, l, [])
+        concat l
 
      solve(leqs : L EQ RE, lvar : L S) : L L EQ RE ==
         lexpr : L RE := [lhs(eq)-rhs(eq) for eq in leqs]
diff --git a/src/algebra/xlpoly.spad b/src/algebra/xlpoly.spad
index 286f894e..fe1fcfde 100644
--- a/src/algebra/xlpoly.spad
+++ b/src/algebra/xlpoly.spad
@@ -293,7 +293,7 @@ LyndonWord(VarSet : OrderedSet) : Public == Private where
 
        LyndonWordsList (vl, n) ==
            v : ARRAY1 List % := LyndonWordsList1(vl, n)
-           "append"/ [v.i for i in 1..n]
+           concat [v.i for i in 1..n]
 
 
 )abbrev category LIECAT LieAlgebra

Reply via email to