diff options
author | Gabriel Dos Reis <gdr@axiomatics.org> | 2016-01-17 22:53:01 -0800 |
---|---|---|
committer | Gabriel Dos Reis <gdr@axiomatics.org> | 2016-01-17 22:53:01 -0800 |
commit | d07fc9735f40e545edda456e15dbab783c500f6a (patch) | |
tree | 4d9fab82a7085b73a4b00d23389935503fdfc90d /src/algebra | |
parent | 5437d438937eb25eb320fef6e4fd6ebc91ca6dc9 (diff) | |
download | open-axiom-d07fc9735f40e545edda456e15dbab783c500f6a.tar.gz |
subtractIfCan$CancellationAbelianMonoid: return the more principled Maybe %
Diffstat (limited to 'src/algebra')
-rw-r--r-- | src/algebra/Makefile.am | 3 | ||||
-rw-r--r-- | src/algebra/Makefile.in | 3 | ||||
-rw-r--r-- | src/algebra/catdef.spad.pamphlet | 6 | ||||
-rw-r--r-- | src/algebra/gbeuclid.spad.pamphlet | 10 | ||||
-rw-r--r-- | src/algebra/gbintern.spad.pamphlet | 8 | ||||
-rw-r--r-- | src/algebra/idecomp.spad.pamphlet | 9 | ||||
-rw-r--r-- | src/algebra/indexedp.spad.pamphlet | 20 | ||||
-rw-r--r-- | src/algebra/integer.spad.pamphlet | 4 | ||||
-rw-r--r-- | src/algebra/newpoly.spad.pamphlet | 14 | ||||
-rw-r--r-- | src/algebra/ore.spad.pamphlet | 6 | ||||
-rw-r--r-- | src/algebra/polset.spad.pamphlet | 4 | ||||
-rw-r--r-- | src/algebra/poly.spad.pamphlet | 22 | ||||
-rw-r--r-- | src/algebra/product.spad.pamphlet | 8 | ||||
-rw-r--r-- | src/algebra/prtition.spad.pamphlet | 17 | ||||
-rw-r--r-- | src/algebra/updivp.spad.pamphlet | 2 | ||||
-rw-r--r-- | src/algebra/vector.spad.pamphlet | 8 |
16 files changed, 73 insertions, 71 deletions
diff --git a/src/algebra/Makefile.am b/src/algebra/Makefile.am index 88c3a9fc..30385bcc 100644 --- a/src/algebra/Makefile.am +++ b/src/algebra/Makefile.am @@ -516,7 +516,8 @@ strap-1/OASGP.$(FASLEXT): strap-1/ORDSET.$(FASLEXT) strap-1/OAMONS.$(FASLEXT): strap-1/OCAMON.$(FASLEXT) strap-1/ABELGRP.$(FASLEXT): strap-1/CABMON.$(FASLEXT) \ - strap-1/LLINSET.$(FASLEXT) + strap-1/LLINSET.$(FASLEXT) \ + strap-1/MAYBE.$(FASLEXT) strap-1/OAGROUP.$(FASLEXT): strap-1/OCAMON.$(FASLEXT) \ strap-1/ABELGRP.$(FASLEXT) diff --git a/src/algebra/Makefile.in b/src/algebra/Makefile.in index 25cd01a2..fdfb8d04 100644 --- a/src/algebra/Makefile.in +++ b/src/algebra/Makefile.in @@ -2027,7 +2027,8 @@ strap-1/OASGP.$(FASLEXT): strap-1/ORDSET.$(FASLEXT) strap-1/OAMONS.$(FASLEXT): strap-1/OCAMON.$(FASLEXT) strap-1/ABELGRP.$(FASLEXT): strap-1/CABMON.$(FASLEXT) \ - strap-1/LLINSET.$(FASLEXT) + strap-1/LLINSET.$(FASLEXT) \ + strap-1/MAYBE.$(FASLEXT) strap-1/OAGROUP.$(FASLEXT): strap-1/OCAMON.$(FASLEXT) \ strap-1/ABELGRP.$(FASLEXT) diff --git a/src/algebra/catdef.spad.pamphlet b/src/algebra/catdef.spad.pamphlet index 1e9370df..ee556b91 100644 --- a/src/algebra/catdef.spad.pamphlet +++ b/src/algebra/catdef.spad.pamphlet @@ -240,7 +240,7 @@ AbelianGroup(): Category == Join(CancellationAbelianMonoid, LeftLinearSet Intege ++ and \spad{y} i.e. \spad{x + (-y)}. add (x:% - y:%):% == x+(-y) - subtractIfCan(x:%, y:%):Union(%, "failed") == (x-y) :: Union(%,"failed") + subtractIfCan(x:%, y:%) == just(x-y) n:NonNegativeInteger * x:% == (n::Integer) * x import RepeatedDoubling(%) if not (% has Ring) then @@ -514,9 +514,9 @@ BiModule(R:Ring,S:Ring):Category == ++ \spad{c = a+b <=> c-b = a} CancellationAbelianMonoid(): Category == AbelianMonoid with --operations - subtractIfCan: (%,%) -> Union(%,"failed") + subtractIfCan: (%,%) -> Maybe % ++ subtractIfCan(x, y) returns an element z such that \spad{z+y=x} - ++ or "failed" if no such element exists. + ++ or \spad{nothing} if no such element exists. @ diff --git a/src/algebra/gbeuclid.spad.pamphlet b/src/algebra/gbeuclid.spad.pamphlet index 963e210b..5b708afc 100644 --- a/src/algebra/gbeuclid.spad.pamphlet +++ b/src/algebra/gbeuclid.spad.pamphlet @@ -389,9 +389,8 @@ EuclideanGroebnerBasisPackage(Dom, Expon, VarSet, Dpol): T == C where ds:= degree s lf1:= leadingCoefficient(f1) ls:= leadingCoefficient(s) - e: Union(Expon, "failed") - (((e:= subtractIfCan(ds, degree f1)) case "failed" ) or sizeLess?(ls, lf1) ) => - eRed(s, rest(H), Hh) + e := subtractIfCan(ds, degree f1) + ((e case nothing) or sizeLess?(ls, lf1) ) => eRed(s, rest(H), Hh) sdf1:= divide(ls, lf1) q1:= sdf1.quotient sdf1.remainder = 0 => @@ -414,9 +413,8 @@ EuclideanGroebnerBasisPackage(Dom, Expon, VarSet, Dpol): T == C where --- crit M - true, if lcm#2 multiple of lcm#1 ecritM(e1: Expon, c1: Dom, e2: Expon, c2: Dom) == - en: Union(Expon, "failed") - ((en:=subtractIfCan(e2, e1)) case "failed") or - ((c2 exquo c1) case "failed") => false + en := subtractIfCan(e2, e1) + (en case nothing) or ((c2 exquo c1) case "failed") => false true ---------------------------- diff --git a/src/algebra/gbintern.spad.pamphlet b/src/algebra/gbintern.spad.pamphlet index 77e72e6f..d6d37fd9 100644 --- a/src/algebra/gbintern.spad.pamphlet +++ b/src/algebra/gbintern.spad.pamphlet @@ -264,8 +264,8 @@ GroebnerInternalPackage(Dom, Expon, VarSet, Dpol): T == C where while not ( s = 0 or null F ) repeat f1:= first(F) s1:= degree(s) - e: Union(Expon, "failed") - (e:= subtractIfCan(s1, degree(f1))) case Expon => + e := subtractIfCan(s1, degree(f1)) + e case Expon => cc:=gcdCo(leadingCoefficient f1, leadingCoefficient s) s:=cc.co1*reductum(s) - monomial(cc.co2,e)*reductum(f1) m := m*cc.co1 @@ -286,8 +286,8 @@ GroebnerInternalPackage(Dom, Expon, VarSet, Dpol): T == C where --- crit M - true, if lcm#2 multiple of lcm#1 critM(e1: Expon, e2: Expon) == - en: Union(Expon, "failed") - (en:=subtractIfCan(e2, e1)) case Expon + en := subtractIfCan(e2, e1) + en case Expon ---------------------------- diff --git a/src/algebra/idecomp.spad.pamphlet b/src/algebra/idecomp.spad.pamphlet index 51ff3a62..9e53d263 100644 --- a/src/algebra/idecomp.spad.pamphlet +++ b/src/algebra/idecomp.spad.pamphlet @@ -298,15 +298,16 @@ IdealDecompositionPackage(vl,nv) : C == T -- take away nv, now doesn't Jd:=generators(groebner J) not one?(#(factors factor Jd.last)) => return false i:=subtractIfCan(#truelist,1) - (i case "failed") => return true + (i case nothing) => return true + k: NNI := i JR:=(reverse Jd);JM:=groebnerIdeal([JR.first]);JP:List(DPoly):=[] for f in JR.rest repeat - if not ismonic(f,truelist.i) then + if not ismonic(f,truelist.k) then if not inRadical?(f,JM) then return false JP:=cons(f,JP) else - x:=truelist.i - i:=(i-1)::NNI + x:=truelist.k + k := (k-1)::NNI if not testPower(univariate(f,x),x,JM) then return false JM :=groebnerIdeal(append(cons(f,JP),generators JM)) true diff --git a/src/algebra/indexedp.spad.pamphlet b/src/algebra/indexedp.spad.pamphlet index beee92ac..e4dd5805 100644 --- a/src/algebra/indexedp.spad.pamphlet +++ b/src/algebra/indexedp.spad.pamphlet @@ -293,19 +293,19 @@ IndexedDirectProductOrderedAbelianMonoidSup(A:OrderedAbelianMonoidSup,S:OrderedS s: S subtractIfCan(x,y) == - empty? y => x - empty? x => "failed" - x.first.k < y.first.k => "failed" + empty? y => just x + empty? x => nothing + x.first.k < y.first.k => nothing x.first.k > y.first.k => t:= subtractIfCan(x.rest, y) - t case "failed" => "failed" - cons( x.first, t) - u:=subtractIfCan(x.first.c, y.first.c) - u case "failed" => "failed" + t case nothing => nothing + just cons( x.first, t) + u := subtractIfCan(x.first.c, y.first.c) + u case nothing => nothing zero? u => subtractIfCan(x.rest, y.rest) - t:= subtractIfCan(x.rest, y.rest) - t case "failed" => "failed" - cons([x.first.k,u],t) + t := subtractIfCan(x.rest, y.rest) + t case nothing => nothing + just cons([x.first.k,u],t) sup(x,y) == empty? y => x diff --git a/src/algebra/integer.spad.pamphlet b/src/algebra/integer.spad.pamphlet index a91b6d63..fde8ef88 100644 --- a/src/algebra/integer.spad.pamphlet +++ b/src/algebra/integer.spad.pamphlet @@ -251,8 +251,8 @@ NonNegativeInteger: Join(OrderedAbelianMonoidSup,Monoid) with shift(x:%, n:Integer):% == ASH(x,n)$Lisp subtractIfCan(x, y) == c:Integer := rep x - rep y - negative? c => "failed" - per c + negative? c => nothing + just per c @ diff --git a/src/algebra/newpoly.spad.pamphlet b/src/algebra/newpoly.spad.pamphlet index 65bdcde7..d695d8ee 100644 --- a/src/algebra/newpoly.spad.pamphlet +++ b/src/algebra/newpoly.spad.pamphlet @@ -120,7 +120,7 @@ NewSparseUnivariatePolynomial(R): Exports == Implementation where e := yy.first.k; y := per(yy.rest) -- while (not empty? xx) repeat repeat - if (u:=subtractIfCan(xx.first.k,e)) case "failed" then break + if (u:=subtractIfCan(xx.first.k,e)) case nothing then break xx:= rep fmecg(per rest(xx), u, xx.first.c, y) if empty? xx then break per xx @@ -134,7 +134,7 @@ NewSparseUnivariatePolynomial(R): Exports == Implementation where empty? xx => [x, co, 0] pow: NNI := 0; e := yy.first.k; y := per(yy.rest); repeat - if (u:=subtractIfCan(xx.first.k,e)) case "failed" then break + if (u:=subtractIfCan(xx.first.k,e)) case nothing then break xx:= rep fmecg(co * per rest(xx), u, xx.first.c, y) pow := pow + 1 if empty? xx then break @@ -151,7 +151,7 @@ NewSparseUnivariatePolynomial(R): Exports == Implementation where (co = -1) => - monicModulo(-x,-y) xx:= rep x; e := yy.first.k; y := per(yy.rest) repeat - if (u:=subtractIfCan(xx.first.k,e)) case "failed" then break + if (u:=subtractIfCan(xx.first.k,e)) case nothing then break xx:= rep fmecg(co * per rest(xx), u, xx.first.c, y) if empty? xx then break per xx @@ -167,7 +167,7 @@ NewSparseUnivariatePolynomial(R): Exports == Implementation where pow: NNI := subtractIfCan(xx.first.k,e)::NNI + 1 qq: Rep := []; y := per(yy.rest) repeat - if (u:=subtractIfCan(xx.first.k,e)) case "failed" then break + if (u:=subtractIfCan(xx.first.k,e)) case nothing then break qq := cons([u::NNI, xx.first.c]$Term, rep (co * per qq)) xx := rep fmecg(co * per rest(xx), u, xx.first.c, y) pow := subtractIfCan(pow,1)::NNI @@ -183,7 +183,7 @@ NewSparseUnivariatePolynomial(R): Exports == Implementation where (empty? xx) or (xx.first.k < e) => 0 qq: Rep := []; co := yy.first.c; y := per(yy.rest) repeat - if (u:=subtractIfCan(xx.first.k,e)) case "failed" then break + if (u:=subtractIfCan(xx.first.k,e)) case nothing then break qq := cons([u::NNI, xx.first.c]$Term, rep (co * per qq)) xx := rep fmecg(co * per rest(xx), u, xx.first.c, y) if empty? xx then break @@ -236,7 +236,7 @@ NewSparseUnivariatePolynomial(R): Exports == Implementation where pow: NNI := subtractIfCan(xx.first.k,e)::NNI + 1 qq: Rep := []; y := per(yy.rest) repeat - if (u:=subtractIfCan(xx.first.k,e)) case "failed" then break + if (u:=subtractIfCan(xx.first.k,e)) case nothing then break qq := cons([u::NNI, xx.first.c]$Term, rep (co * per qq)) xx := rep fmecg(co * per rest(xx), u, xx.first.c, y) pow := subtractIfCan(pow,1)::NNI @@ -257,7 +257,7 @@ NewSparseUnivariatePolynomial(R): Exports == Implementation where pow: NNI := subtractIfCan(xx.first.k,e)::NNI + 1 qq: Rep := []; co := yy.first.c; y := per(yy.rest) repeat - if (u:=subtractIfCan(xx.first.k,e)) case "failed" then break + if (u:=subtractIfCan(xx.first.k,e)) case nothing then break qq := cons([u::NNI, xx.first.c]$Term, rep (co * per qq)) xx := rep fmecg(co * per rest(xx), u, xx.first.c, y) pow := subtractIfCan(pow,1)::NNI diff --git a/src/algebra/ore.spad.pamphlet b/src/algebra/ore.spad.pamphlet index 3aaeab04..1167ea57 100644 --- a/src/algebra/ore.spad.pamphlet +++ b/src/algebra/ore.spad.pamphlet @@ -400,7 +400,7 @@ UnivariateSkewPolynomialCategoryOps(R, C): Exports == Implementation where termPoly(a, n, y, sigma, delta) == zero? y => 0 - (u := subtractIfCan(n, 1)) case "failed" => a * y + (u := subtractIfCan(n, 1)) case nothing => a * y n1 := u::N z:C := 0 while y ~= 0 repeat @@ -424,7 +424,7 @@ UnivariateSkewPolynomialCategoryOps(R, C): Exports == Implementation where localLeftDivide(a, b, sigma, b1) == zero? b => error "leftDivide: division by 0" zero? a or - (n := subtractIfCan(degree(a),(m := degree b))) case "failed" => + (n := subtractIfCan(degree(a),(m := degree b))) case nothing => [0,a] q := monomial((sigma**(-m))(b1 * leadingCoefficient a), n::N) qr := localLeftDivide(a - b * q, b, sigma, b1) @@ -435,7 +435,7 @@ UnivariateSkewPolynomialCategoryOps(R, C): Exports == Implementation where localRightDivide(a, b, sigma, b1) == zero? b => error "rightDivide: division by 0" zero? a or - (n := subtractIfCan(degree(a),(m := degree b))) case "failed" => + (n := subtractIfCan(degree(a),(m := degree b))) case nothing => [0,a] q := monomial(leadingCoefficient(a) * (sigma**n) b1, n::N) qr := localRightDivide(a - q * b, b, sigma, b1) diff --git a/src/algebra/polset.spad.pamphlet b/src/algebra/polset.spad.pamphlet index 2752335c..bcd9bfc3 100644 --- a/src/algebra/polset.spad.pamphlet +++ b/src/algebra/polset.spad.pamphlet @@ -268,10 +268,10 @@ PolynomialSetCategory(R:Ring, E:OrderedAbelianMonoidSup,_ r : R := 1$R lp1 := sort(localInf?, reverse elements(ps)) lp2 := lp1 - e : Union(E, "failed") while (not zero? a) and (not empty? lp2) repeat p := first lp2 - if ((e:= subtractIfCan(degree(a),degree(p))) case E) + e := subtractIfCan(degree(a),degree(p)) + if e case E then g := gcd((lca := leadingCoefficient(a)),(lcp := leadingCoefficient(p)))$R (lca,lcp) := (exactQuo(lca,g),exactQuo(lcp,g)) diff --git a/src/algebra/poly.spad.pamphlet b/src/algebra/poly.spad.pamphlet index aeca4bf1..c9f16e71 100644 --- a/src/algebra/poly.spad.pamphlet +++ b/src/algebra/poly.spad.pamphlet @@ -331,8 +331,8 @@ PolynomialRing(R:Ring,E:OrderedAbelianMonoid): T == C while not null p1 repeat (a:= p1.first.c exquo p2.first.c) a case "failed" => return "failed" - ee:= subtractIfCan(p1.first.k, p2.first.k) - ee case "failed" => return "failed" + ee := subtractIfCan(p1.first.k, p2.first.k) + ee case nothing => return "failed" p1:= fmecg(p1.rest, ee, a, p2.rest) rout:= [[ee,a], :rout] null p1 => reverse(rout)::% -- nreverse? @@ -346,8 +346,8 @@ PolynomialRing(R:Ring,E:OrderedAbelianMonoid): T == C while not null p1 repeat (a:= p1.first.c exquo p2.first.c) a case "failed" => return "failed" - ee:= subtractIfCan(p1.first.k, p2.first.k) - ee case "failed" => return "failed" + ee := subtractIfCan(p1.first.k, p2.first.k) + ee case nothing => return "failed" p1:= fmecg(p1.rest, ee, a, p2.rest) rout:= [[ee,a], :rout] null p1 => reverse(rout)::% -- nreverse? @@ -539,8 +539,8 @@ SparseUnivariatePolynomial(R:Ring): UnivariatePolynomialCategory(R) with while not null p1 repeat (a:= p1.first.c exquo p2.first.c) a case "failed" => return "failed" - ee:= subtractIfCan(p1.first.k, p2.first.k) - ee case "failed" => return "failed" + ee := subtractIfCan(p1.first.k, p2.first.k) + ee case nothing => return "failed" p1:= fmecg(p1.rest, ee, a, p2.rest) rout:= [[ee,a], :rout] null p1 => reverse(rout)::% -- nreverse? @@ -554,8 +554,8 @@ SparseUnivariatePolynomial(R:Ring): UnivariatePolynomialCategory(R) with while not null p1 repeat (a:= p1.first.c exquo p2.first.c) a case "failed" => return "failed" - ee:= subtractIfCan(p1.first.k, p2.first.k) - ee case "failed" => return "failed" + ee := subtractIfCan(p1.first.k, p2.first.k) + ee case nothing => return "failed" p1:= fmecg(p1.rest, ee, a, p2.rest) rout:= [[ee,a], :rout] null p1 => reverse(rout)::% -- nreverse? @@ -581,7 +581,7 @@ SparseUnivariatePolynomial(R:Ring): UnivariatePolynomialCategory(R) with p2:=p2.rest; e1:=max(p1.first.k:Integer-e+1,0):NonNegativeInteger while not null p1 repeat - if (u:=subtractIfCan(p1.first.k,e)) case "failed" then leave + if (u:=subtractIfCan(p1.first.k,e)) case nothing then leave p1:=fmecg(co * p1.rest, u, p1.first.c, p2) e1:= (e1 - 1):NonNegativeInteger e1 = 0 => p1 @@ -628,7 +628,7 @@ SparseUnivariatePolynomial(R:Ring): UnivariatePolynomialCategory(R) with rout:Rep := [] p2 := p2.rest while not null p1 repeat - (u:=subtractIfCan(p1.first.k, n)) case "failed" => leave + (u:=subtractIfCan(p1.first.k, n)) case nothing => leave rout:=[[u, p1.first.c], :rout] p1:=fmecg(p1.rest, rout.first.k, rout.first.c, p2) [reverse!(rout),p1] @@ -697,7 +697,7 @@ SparseUnivariatePolynomial(R:Ring): UnivariatePolynomialCategory(R) with p2:=p2.rest rout:=empty()$List(Term) while p1 ~= 0 repeat - (u:=subtractIfCan(p1.first.k, n)) case "failed" => leave + (u:=subtractIfCan(p1.first.k, n)) case nothing => leave rout:=[[u, ct * p1.first.c], :rout] p1:=fmecg(p1.rest, rout.first.k, rout.first.c, p2) [reverse!(rout),p1] diff --git a/src/algebra/product.spad.pamphlet b/src/algebra/product.spad.pamphlet index e10d11a8..94635e44 100644 --- a/src/algebra/product.spad.pamphlet +++ b/src/algebra/product.spad.pamphlet @@ -80,10 +80,10 @@ Product (A:SetCategory,B:SetCategory) : C == T if A has CancellationAbelianMonoid and B has CancellationAbelianMonoid then - subtractIfCan(x, y) : Union(%,"failed") == - (na:= subtractIfCan(x.acomp, y.acomp)) case "failed" => "failed" - (nb:= subtractIfCan(x.bcomp, y.bcomp)) case "failed" => "failed" - [na::A,nb::B] + subtractIfCan(x, y) == + (na:= subtractIfCan(x.acomp, y.acomp)) case nothing => nothing + (nb:= subtractIfCan(x.bcomp, y.bcomp)) case nothing => nothing + just [na::A,nb::B] if A has AbelianGroup and B has AbelianGroup then - x == [- x.acomp,-x.bcomp] diff --git a/src/algebra/prtition.spad.pamphlet b/src/algebra/prtition.spad.pamphlet index 6fc92821..56acfbda 100644 --- a/src/algebra/prtition.spad.pamphlet +++ b/src/algebra/prtition.spad.pamphlet @@ -91,17 +91,18 @@ Partition(): Exports == Implementation where zero? n => 0 x + (subtractIfCan(n,1) :: NNI) * x - remv(i: PI,x: %): UN == - member?(i,rep x) => per remove(i, rep x)$Rep - "failed" + remv(i: PI,x: %): Maybe % == + member?(i,rep x) => just per remove(i, rep x)$Rep + nothing subtractIfCan(x, y) == zero? x => - zero? y => 0 - "failed" - zero? y => x - (aa := remv(first rep y,x)) case "failed" => "failed" - subtractIfCan((aa :: %), per rest rep y) + zero? y => just 0 + nothing + zero? y => just x + aa := remv(first rep y,x) + aa case nothing => nothing + subtractIfCan(aa@%, per rest rep y) powers x == l := rep x diff --git a/src/algebra/updivp.spad.pamphlet b/src/algebra/updivp.spad.pamphlet index efeb3cca..0ceeefb3 100644 --- a/src/algebra/updivp.spad.pamphlet +++ b/src/algebra/updivp.spad.pamphlet @@ -43,7 +43,7 @@ UnivariatePolynomialDivisionPackage(R,UP): Exports == Implementation where zero? p2 => error "divideIfCan: division by zero" one? (lc := leadingCoefficient p2) => monicDivide(p1,p2) q: UP := 0 - while not ((e := subtractIfCan(degree(p1),degree(p2))) case "failed") + while not ((e := subtractIfCan(degree(p1),degree(p2))) case nothing) repeat c := leadingCoefficient(p1) exquo lc c case "failed" => return "failed" diff --git a/src/algebra/vector.spad.pamphlet b/src/algebra/vector.spad.pamphlet index 7d143b7a..38b14e15 100644 --- a/src/algebra/vector.spad.pamphlet +++ b/src/algebra/vector.spad.pamphlet @@ -340,13 +340,13 @@ DirectProduct(dim:NonNegativeInteger, R:Type): if R has CancellationAbelianMonoid then - subtractIfCan(u:%, v:%):Union(%,"failed") == + subtractIfCan(u:%, v:%) == w := new(dim,0)$Vector(R) for i in 1..dim repeat - (c := subtractIfCan(qelt(rep u, i), qelt(rep v,i))) case "failed" => - return "failed" + (c := subtractIfCan(qelt(rep u, i), qelt(rep v,i))) case nothing => + return nothing qsetelt!(w, i, c::R) - per w + just per w if R has Ring then |