diff options
author | dos-reis <gdr@axiomatics.org> | 2008-05-11 19:14:29 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2008-05-11 19:14:29 +0000 |
commit | 20e1bed66399cce629d08a71ca0552ed24fef1d1 (patch) | |
tree | 000ab5b98e479d1c077fc4f6fd4a9f46c4a9451c | |
parent | 51422a0c6bc0128cd5635a01c402ef56ad4ed770 (diff) | |
download | open-axiom-20e1bed66399cce629d08a71ca0552ed24fef1d1.tar.gz |
Restrict loop variable scopes, take 2.
* interp/iterator.boot (compReduce1): Maintain proper scope for
loop variables.
(compRepeatOrCollect): Really maintain proper scope for loop variables.
* interp/compiler.boot (eltModemapFilter): Highlight faulty selector.
(seteltModemapFilter): Likewise.
* interp/c-util.boot (stackMessage): Don't build message if there
is no argument for substitution.
* algebra/aggcat.spad.pamphlet (#$UnaryRecursiveAggregate):
Declare free loop variable.
(cycleEntry$UnaryRecursiveAggregate): Likewise.
(cycleLength): Likewise.
(merge$OneDimensionalArrayAggregate): Likewise.
(delete$OneDimensionalArrayAggregate): Likewise.
(position$ListAggregate): Likewise.
* algebra/array1.spad.pamphlet (merge!$IndexedFlexibleArray): Likewise.
* algebra/combfunc.spad.pamphlet (K2fact$CombinatorialFunction):
Likewise.
* algebra/curve.spad.pamphlet
(nonSingularModel$FunctionFieldCategory): Likewise.
* algebra/dpolcat.spad.pamphlet
(differentiate$DifferentialPolynomialCategory): Likewise.
* algebra/efstruc.spad.pamphlet
(validExponential$ElementaryFunctionStructurePackage): Likewise.
(ker2explogs$InnerTrigonometricManipulations): Likewise.
(complexNormalize$TrigonometricManipulations): Likewise.
36 files changed, 140 insertions, 28 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 9f26d1d3..a09aa479 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,32 @@ +2008-05-11 Gabriel Dos Reis <gdr@cs.tamu.edu> + + Restrict loop variable scopes, take 2. + * interp/iterator.boot (compReduce1): Maintain proper scope for + loop variables. + (compRepeatOrCollect): Really maintain proper scope for loop variables. + * interp/compiler.boot (eltModemapFilter): Highlight faulty selector. + (seteltModemapFilter): Likewise. + * interp/c-util.boot (stackMessage): Don't build message if there + is no argument for substitution. + * algebra/aggcat.spad.pamphlet (#$UnaryRecursiveAggregate): + Declare free loop variable. + (cycleEntry$UnaryRecursiveAggregate): Likewise. + (cycleLength): Likewise. + (merge$OneDimensionalArrayAggregate): Likewise. + (delete$OneDimensionalArrayAggregate): Likewise. + (position$ListAggregate): Likewise. + * algebra/array1.spad.pamphlet (merge!$IndexedFlexibleArray): Likewise. + * algebra/combfunc.spad.pamphlet (K2fact$CombinatorialFunction): + Likewise. + * algebra/curve.spad.pamphlet + (nonSingularModel$FunctionFieldCategory): Likewise. + * algebra/dpolcat.spad.pamphlet + (differentiate$DifferentialPolynomialCategory): Likewise. + * algebra/efstruc.spad.pamphlet + (validExponential$ElementaryFunctionStructurePackage): Likewise. + (ker2explogs$InnerTrigonometricManipulations): Likewise. + (complexNormalize$TrigonometricManipulations): Likewise. + 2008-05-10 Gabriel Dos Reis <gdr@cs.tamu.edu> * interp/iterator.boot (compRepeatOrCollect): Don't iterator diff --git a/src/algebra/aggcat.spad.pamphlet b/src/algebra/aggcat.spad.pamphlet index a308f1e6..af724ec4 100644 --- a/src/algebra/aggcat.spad.pamphlet +++ b/src/algebra/aggcat.spad.pamphlet @@ -2507,6 +2507,7 @@ UnaryRecursiveAggregate(S:Type): Category == RecursiveAggregate S with empty? l and zero? i #x == + k : NonNegativeInteger for k in 0.. while not empty? x repeat k = cycleMax and cyclic? x => error "cyclic list" x := rest x @@ -2541,6 +2542,7 @@ UnaryRecursiveAggregate(S:Type): Category == RecursiveAggregate S with empty? x => x empty?(y := findCycle x) => y z := rest y + l : NonNegativeInteger for l in 1.. while not eq?(y,z) repeat z := rest z y := x for k in 1..l repeat y := rest y @@ -2551,6 +2553,7 @@ UnaryRecursiveAggregate(S:Type): Category == RecursiveAggregate S with empty? x => 0 empty?(x := findCycle x) => 0 y := rest x + k : NonNegativeInteger for k in 1.. while not eq?(x,y) repeat y := rest y k @@ -4286,6 +4289,7 @@ OneDimensionalArrayAggregate(S:Type): Category == m := maxIndex a j := minIndex b n := maxIndex b + k : Integer for k in minIndex(r).. while i <= m and j <= n repeat if f(qelt(a, i), qelt(b, j)) then qsetelt_!(r, k, qelt(a, i)) @@ -4311,6 +4315,7 @@ OneDimensionalArrayAggregate(S:Type): Category == n := maxIndex b i < m or i > n => error "index out of range" y := stupidnew(#a + #b, a, b) + k : Integer for k in minIndex y.. for j in m..i-1 repeat qsetelt_!(y, k, qelt(b, j)) for k in k.. for j in minIndex a .. maxIndex a repeat @@ -4343,6 +4348,7 @@ OneDimensionalArrayAggregate(S:Type): Category == l < minIndex a or h > maxIndex a => error "index out of range" h < l => copy a r := stupidnew((#a - h + l - 1)::NonNegativeInteger, a, a) + k : Integer for k in minIndex(r).. for i in minIndex a..l-1 repeat qsetelt_!(r, k, qelt(a, i)) for k in k.. for i in h+1 .. maxIndex a repeat @@ -4352,6 +4358,7 @@ OneDimensionalArrayAggregate(S:Type): Category == delete(x:%, i:Integer) == i < minIndex x or i > maxIndex x => error "index out of range" y := stupidnew((#x - 1)::NonNegativeInteger, x, x) + i : Integer for i in minIndex(y).. for j in minIndex x..i-1 repeat qsetelt_!(y, i, qelt(x, j)) for i in i .. for j in i+1 .. maxIndex x repeat @@ -4586,6 +4593,7 @@ ListAggregate(S:Type): Category == Join(StreamAggregate S, first x position(f:S -> Boolean, x:%) == + k : Integer for k in minIndex(x).. while not empty? x and not f first x repeat x := rest x empty? x => minIndex(x) - 1 @@ -4679,6 +4687,7 @@ ListAggregate(S:Type): Category == Join(StreamAggregate S, position(w, x, s) == s < (m := minIndex x) => error "index out of range" x := rest(x, (s - m)::NonNegativeInteger) + k : Integer for k in s.. while not empty? x and w ~= first x repeat x := rest x empty? x => minIndex x - 1 diff --git a/src/algebra/array1.spad.pamphlet b/src/algebra/array1.spad.pamphlet index 87ba8034..f5591e0b 100644 --- a/src/algebra/array1.spad.pamphlet +++ b/src/algebra/array1.spad.pamphlet @@ -508,6 +508,7 @@ IndexedFlexibleArray(S:Type, mn: Integer): Exports == Implementation where m := #a; n := #b; growAdding(a, n, b) for i in m-1..0 by -1 for j in m+n-1.. by -1 repeat a.f.j := a.f.i i := n; j := 0 + k : Integer for k in 0.. while i < n+m and j < n repeat if g(a.f.i,b.f.j) then (a.f.k := a.f.i; i := i+1) else (a.f.k := b.f.j; j := j+1) diff --git a/src/algebra/combfunc.spad.pamphlet b/src/algebra/combfunc.spad.pamphlet index ffbf5887..aa560163 100644 --- a/src/algebra/combfunc.spad.pamphlet +++ b/src/algebra/combfunc.spad.pamphlet @@ -398,6 +398,7 @@ dummy variable is introduced to make the indexing variable \lq local\rq. IndexedExponents K, K, R, SMP, F) K2fact(k, l) == + kf : F empty? [v for v in variables(kf := k::F) | member?(v, l)] => kf empty?(args:List F := [facts(a, l) for a in argument k]) => kf is?(k, opperm) => diff --git a/src/algebra/curve.spad.pamphlet b/src/algebra/curve.spad.pamphlet index d216b16d..7f959605 100644 --- a/src/algebra/curve.spad.pamphlet +++ b/src/algebra/curve.spad.pamphlet @@ -213,7 +213,8 @@ FunctionFieldCategory(F, UP, UPUP): Category == Definition where nonSingularModel u == d := commonDenominator(coordinates(w := integralBasis()))::RF - vars := [concat(string u, string i)::SY for i in 1..(n := #w)] + n := #w + vars := [concat(string u, string i)::SY for i in 1..n] x := "%%dummy1"::SY y := "%%dummy2"::SY select_!(zero?(degree(#1, x)) and zero?(degree(#1, y)), diff --git a/src/algebra/dpolcat.spad.pamphlet b/src/algebra/dpolcat.spad.pamphlet index 2a170259..2ee6eb4f 100644 --- a/src/algebra/dpolcat.spad.pamphlet +++ b/src/algebra/dpolcat.spad.pamphlet @@ -322,6 +322,7 @@ DifferentialPolynomialCategory(R:Ring,S:OrderedSet, differentiate(p:$, d:R -> R) == ans:$ := 0 l := variables p + u : Union(R, "failed") while (u:=retractIfCan(p)@Union(R, "failed")) case "failed" repeat t := leadingMonomial p lc := leadingCoefficient t diff --git a/src/algebra/efstruc.spad.pamphlet b/src/algebra/efstruc.spad.pamphlet index 9a015122..a73963fd 100644 --- a/src/algebra/efstruc.spad.pamphlet +++ b/src/algebra/efstruc.spad.pamphlet @@ -439,6 +439,7 @@ ElementaryFunctionStructurePackage(R,F): Exports == Implementation where f validExponential(twr, eta, x) == + fns : List F (c := solveLinearlyOverQ(construct([differentiate(g, x) for g in (fns := toY twr)]$List(F))@Vector(F), differentiate(eta, x))) case "failed" => "failed" @@ -565,6 +566,7 @@ InnerTrigonometricManipulations(R,F,FG): Exports == Implementation where -- This expects the argument to have only tan and atans left. -- Does a half-angle correction if k is not in the initial kernel list. ker2explogs(k, l, lx) == + kf : FG empty?([v for v in variables(kf := k::FG) | member?(v, lx)]$List(SY)) => kf empty?(args := [trigs2explogs(a, l, lx) @@ -762,6 +764,7 @@ TrigonometricManipulations(R, F): Exports == Implementation where F2FG g complexNormalize(f, x) == + g : F any?(has?(operator #1, "rtrig"), [k for k in tower(g := realElementary(f, x)) | member?(x, variables(k::F))]$List(K))$List(K) => @@ -778,6 +781,7 @@ TrigonometricManipulations(R, F): Exports == Implementation where g complexElementary(f, x) == + g : F any?(has?(operator #1, "rtrig"), [k for k in tower(g := realElementary(f, x)) | member?(x, variables(k::F))]$List(K))$List(K) => @@ -882,6 +886,7 @@ ComplexTrigonometricManipulations(R, F): Exports == Implementation where g complexElementary(f, x) == + g : F any?(has?(operator #1, "rtrig"), [k for k in tower(g := realElementary(f, x)) | member?(x, variables(k::F))]$List(K))$List(K) => @@ -889,6 +894,7 @@ ComplexTrigonometricManipulations(R, F): Exports == Implementation where g complexNormalize(f, x) == + g : F any?(has?(operator #1, "rtrig"), [k for k in tower(g := realElementary(f, x)) | member?(x, variables(k::F))]$List(K))$List(K) => diff --git a/src/algebra/ffpoly.spad.pamphlet b/src/algebra/ffpoly.spad.pamphlet index acebb710..ee544ce5 100644 --- a/src/algebra/ffpoly.spad.pamphlet +++ b/src/algebra/ffpoly.spad.pamphlet @@ -436,6 +436,7 @@ FiniteFieldPolynomialPackage GF : Exports == Implementation where -- we can not simply write fcopy := copy fRepr because -- the input(!) f would be modified by assigning -- a new value to one of its records + term : Rec for term in fRepr repeat fcopy := cons(copy term, fcopy) if term.expnt ~= 0 then @@ -513,6 +514,7 @@ FiniteFieldPolynomialPackage GF : Exports == Implementation where -- we can not simply write fcopy := copy fRepr because -- the input(!) f would be modified by assigning -- a new value to one of its records + term : Rec for term in fRepr repeat fcopy := cons(copy term, fcopy) if term.expnt ~= 0 then @@ -632,6 +634,7 @@ FiniteFieldPolynomialPackage GF : Exports == Implementation where -- we can not simply write fcopy := copy fRepr because -- the input(!) f would be modified by assigning -- a new value to one of its records + term : Rec for term in fRepr repeat fcopy := cons(copy term, fcopy) if term.expnt ~= 0 then @@ -745,6 +748,7 @@ FiniteFieldPolynomialPackage GF : Exports == Implementation where -- we can not simply write fcopy := copy fRepr because -- the input(!) f would be modified by assigning -- a new value to one of its records + term : Rec for term in fRepr repeat fcopy := cons(copy term, fcopy) if term.expnt ~= 0 then diff --git a/src/algebra/fraction.spad.pamphlet b/src/algebra/fraction.spad.pamphlet index a54b4f61..bb9fbee4 100644 --- a/src/algebra/fraction.spad.pamphlet +++ b/src/algebra/fraction.spad.pamphlet @@ -252,6 +252,7 @@ QuotientFieldCategory(S: IntegralDomain): Category == if S has IntegerNumberSystem then random():% == + d : S while zero?(d:=random()$S) repeat d random()$S / d diff --git a/src/algebra/galfact.spad.pamphlet b/src/algebra/galfact.spad.pamphlet index 8d9a6a02..0e06b615 100644 --- a/src/algebra/galfact.spad.pamphlet +++ b/src/algebra/galfact.spad.pamphlet @@ -290,6 +290,7 @@ GaloisGroupFactorizer(UP): Exports == Implementation where if (l := length n)<levels then return(n+shift(1,l-1)) (n=shift(seed(level),levels-level)) => "End of level" b: Z := 1 + lr : Z while ((l-b) = (lr := length(n := reductum n)))@Boolean repeat b := b+1 reductum(n)+shift(seed(b+1),lr) diff --git a/src/algebra/gpgcd.spad.pamphlet b/src/algebra/gpgcd.spad.pamphlet index 85f20722..5b5c4510 100644 --- a/src/algebra/gpgcd.spad.pamphlet +++ b/src/algebra/gpgcd.spad.pamphlet @@ -265,6 +265,7 @@ GeneralPolynomialGcdPackage(E,OV,R,P):C == T where #lv = 0 => p1 lr:=[ randomR() for vv in lv] dg:=degree p1 + ans : SUPP while dg ~= degree (ans:= map(eval(#1,lv,lr),p1)) repeat lr:=[ randomR() for vv in lv] ans diff --git a/src/algebra/integrat.spad.pamphlet b/src/algebra/integrat.spad.pamphlet index f70dfe1c..ab2eb2be 100644 --- a/src/algebra/integrat.spad.pamphlet +++ b/src/algebra/integrat.spad.pamphlet @@ -71,6 +71,7 @@ FunctionSpaceComplexIntegration(R, F): Exports == Implementation where internalIntegrate(f, x) == f := distribute(f, x::F) + g : F any?(has?(operator #1, "rtrig"), [k for k in tower(g := realElementary(f, x)) | member?(x, variables(k::F))]$List(Kernel F))$List(Kernel F) => diff --git a/src/algebra/intfact.spad.pamphlet b/src/algebra/intfact.spad.pamphlet index f5485d51..4d4cc811 100644 --- a/src/algebra/intfact.spad.pamphlet +++ b/src/algebra/intfact.spad.pamphlet @@ -156,6 +156,7 @@ IntegerPrimesPackage(I:IntegerNumberSystem): with nm1 := n-1 q := (nm1) quo two + k : NonNegativeInteger for k in 1.. while not odd? q repeat q := q quo two -- q = (n-1) quo 2**k for largest possible k @@ -378,6 +379,8 @@ IntegerFactorizationPackage(I): Exports == Implementation where if n<0 then (m := -n; u := -1) else (m := n; u := 1) (m > 1) and ((v := perfectSqrt m) case I) => + sv : FF + l : List FFE for rec in (l := factorList(sv := squareFree(v::I))) repeat rec.xpnt := 2 * rec.xpnt makeFR(u * unit sv, l) @@ -438,6 +441,7 @@ IntegerFactorizationPackage(I): Exports == Implementation where if n<d*d then if n>1 then ls := concat_!(ls, ["prime",n,1]$FFE) return makeFR(1, ls) + m : Integer for m in 0.. while zero?(n rem d) repeat n := n quo d if m>0 then ls := concat_!(ls, ["prime",d,convert m]$FFE) d := d+s @@ -463,7 +467,9 @@ IntegerFactorizationPackage(I): Exports == Implementation where f:LMI := dictionary() -- number which could not be factored insert_!(n, a) while not empty? a repeat - n := inspect a; c := count(n, a); remove_!(n, a) + n := inspect a; + c := count(n, a); + remove_!(n, a) prime?(n)$IntegerPrimesPackage(I) => insert_!(n, b, c) -- test for a perfect power (s := perfectNthRoot n).exponent > 1 => @@ -475,8 +481,9 @@ IntegerFactorizationPackage(I): Exports == Implementation where insert_!(x+y,a,c) insert_!(x-y,a,c) (d := PollardSmallFactor n) case I => - for m in 0.. while zero?(n rem d) repeat n := n quo d - insert_!(d, a, m * c) + m' : NonNegativeInteger + for m' in 0.. while zero?(n rem d) repeat n := n quo d + insert_!(d, a, m' * c) if n > 1 then insert_!(n, a, c) -- an elliptic curve factorization attempt should be made here insert_!(n, f, c) diff --git a/src/algebra/lingrob.spad.pamphlet b/src/algebra/lingrob.spad.pamphlet index 290c39e6..9993e249 100644 --- a/src/algebra/lingrob.spad.pamphlet +++ b/src/algebra/lingrob.spad.pamphlet @@ -128,6 +128,7 @@ LinGroebnerPackage(lv,F) : C == T ofirstmon:=firstmon orecfmon := recfmon lm:=zero(2*ndim+1) + j : Integer for j in 1..ndim repeat lm(j):=veccoef(j) lm(ndim+i):=recfmon.mult lm := reduceRow(linmat, lm, i-1, pivots) @@ -178,6 +179,7 @@ LinGroebnerPackage(lv,F) : C == T omult := (omult exquo cc)::F veccoef:VF:=coord(f,algBasis) lm:=zero(2*ndim+1) + j : Integer for j in 1..ndim repeat lm(j) := veccoef(j) lm(ndim+i):=omult lm := reduceRow(linmat, lm, i-1, pivots) @@ -285,6 +287,7 @@ LinGroebnerPackage(lv,F) : C == T ofirstmon:=firstmon orecfmon := recfmon lm:=zero(2*ndim+1) + j : Integer for j in 1..ndim repeat lm(j):=veccoef(j) lm(ndim+i):=recfmon.mult lm := reduceRow(linmat, lm, i-1, pivots) diff --git a/src/algebra/manip.spad.pamphlet b/src/algebra/manip.spad.pamphlet index 5cad4e61..a9f207d7 100644 --- a/src/algebra/manip.spad.pamphlet +++ b/src/algebra/manip.spad.pamphlet @@ -289,6 +289,7 @@ AlgebraicManipulations(R, F): Exports == Implementation where empty?(l := sort_!(#1 > #2, kernels x)$List(K)) or empty? setIntersection(ll, tower x) => x lk := empty()$List(K) + k : K while not member?(k := first l, ll) repeat lk := concat(k, lk) empty?(l := rest l) => diff --git a/src/algebra/matfuns.spad.pamphlet b/src/algebra/matfuns.spad.pamphlet index 776895ee..d36e02e7 100644 --- a/src/algebra/matfuns.spad.pamphlet +++ b/src/algebra/matfuns.spad.pamphlet @@ -147,6 +147,7 @@ InnerMatrixLinearAlgebraFunctions(R,Row,Col,M):_ -- if the ith row has an initial 1 in the jth column, then -- v.j = i; v.j = minR - 1, otherwise v : IndexedOneDimensionalArray(I,minC) := new(ncol,minR - 1) + j : Integer for i in minR..(minR + rk - 1) repeat for j in minC.. while qelt(x,i,j) = 0 repeat j qsetelt_!(v,j,i) diff --git a/src/algebra/mkfunc.spad.pamphlet b/src/algebra/mkfunc.spad.pamphlet index 8e7f6c39..bb7b4a5c 100644 --- a/src/algebra/mkfunc.spad.pamphlet +++ b/src/algebra/mkfunc.spad.pamphlet @@ -112,7 +112,8 @@ InputForm(): every?(atom?,destruct s)$List(%) => s sy := new()$Symbol n:NonNegativeInteger := 0 - l2 := [flatten0(x, sy, n := n + 1) for x in rest(l := destruct s)] + l := destruct s + l2 := [flatten0(x, sy, n := n + 1) for x in rest l] conv(concat(convert("SEQ"::Symbol)@%, concat(concat [u.lst for u in l2], conv( [convert("exit"::Symbol)@%, 1$%, conv(concat(first l, @@ -121,7 +122,8 @@ InputForm(): flatten0(s, sy, n) == atom? s => [nil(), s] a := convert(concat(string sy, convert(n)@String)::Symbol)@% - l2 := [flatten0(x, sy, n := n+1) for x in rest(l := destruct s)] + l := destruct s + l2 := [flatten0(x, sy, n := n+1) for x in rest l] [concat(concat [u.lst for u in l2], conv([convert( "LET"::Symbol)@%, a, conv(concat(first l, [u.symb for u in l2]))@%]$List(%))@%), a] diff --git a/src/algebra/numtheor.spad.pamphlet b/src/algebra/numtheor.spad.pamphlet index 907bb9f7..1071d36d 100644 --- a/src/algebra/numtheor.spad.pamphlet +++ b/src/algebra/numtheor.spad.pamphlet @@ -405,6 +405,7 @@ IntegerNumberTheoryFunctions(): Exports == Implementation where even? b and positiveRemainder(a,4) > 1 => error "J(a/b) not defined for b even and a = 2 or 3 (mod 4)" even? b and even? a => 0 + k : Integer for k in 0.. while even? b repeat b := b quo 2 j:I := (odd? k and positiveRemainder(a,8) = 5 => -1; 1) b = 1 => j diff --git a/src/algebra/patmatch1.spad.pamphlet b/src/algebra/patmatch1.spad.pamphlet index 1ee6220f..87abc55b 100644 --- a/src/algebra/patmatch1.spad.pamphlet +++ b/src/algebra/patmatch1.spad.pamphlet @@ -528,6 +528,7 @@ PatternMatchTools(S, R, P): Exports == Implementation where generic? p => setIntersection(badValues p, ls) empty() l1:PRS := failed() + t : P for x in setDifference(ls, bad) while (t := x; failed?(l1 := pmatch(x, p, l))) repeat 0 failed? l1 => diff --git a/src/algebra/permgrps.spad.pamphlet b/src/algebra/permgrps.spad.pamphlet index 2014f7b4..c4060112 100644 --- a/src/algebra/permgrps.spad.pamphlet +++ b/src/algebra/permgrps.spad.pamphlet @@ -344,6 +344,7 @@ PermutationGroup(S:SetCategory): public == private where -- try to get a good approximation for the strong generators and base ort: REC k1: NNI + i : NNI for i in number1..degree repeat ort := orbitWithSvc ( group , i ) k := ort.orb @@ -352,6 +353,7 @@ PermutationGroup(S:SetCategory): public == private where gpsgs := nil()$(L V NNI) words2 := nil()$(L L NNI) gplength : NNI := #group + jj: NNI for jj in 1..gplength repeat if (group.jj).i ~= i then leave for k in 1..gplength repeat el2 := group.k @@ -423,7 +425,7 @@ PermutationGroup(S:SetCategory): public == private where if wordProblem then wordlist := append ( wordlist , outword.nnn ) pt := baseLength - nnn + 1 obs := orbitWithSvc ( sgs , baseOfGroup.pt ) - i := 1 + i : NNI := 1 while not ( i > # out.nnn ) repeat pos := position ( out.nnn.i , sgs ) sgs2 := delete(sgs, pos) diff --git a/src/algebra/pfo.spad.pamphlet b/src/algebra/pfo.spad.pamphlet index 1b310c40..493a68e4 100644 --- a/src/algebra/pfo.spad.pamphlet +++ b/src/algebra/pfo.spad.pamphlet @@ -499,15 +499,24 @@ PointsOfFiniteOrder(R0, F, UP, UPUP, R): Exports == Implementation where selIntegers():RC0 == f := definingPolynomial()$R - while zero?(d := doubleDisc(r := polyred pmod f)) repeat newReduc()$q - [r, d] + repeat + r := polyred pmod f + d := doubleDisc r + if zero? d then + newReduc()$q + else + return [r,d] selectIntegers(k:K):REC == g := polyred(f := definingPolynomial()$R) p := minPoly k - while zero?(d := doubleDisc(r := kpmod(g, k))) or (notIrr? fmod p) - repeat newReduc()$q - [r, d, splitDenominator(fmod p).num] + repeat + r := kpmod(g, k) + d := doubleDisc r + if zero? d or notIrr? fmod p then + newReduc()$q + else + return [r, d, splitDenominator(fmod p).num] toQ1(p, d) == map(Q2F(retract(#1 rem d)@Q), @@ -528,6 +537,7 @@ PointsOfFiniteOrder(R0, F, UP, UPUP, R): Exports == Implementation where kgetGoodPrime(rec, res, h, b, d) == p:PI := 3 + u : Union(UPQ, "failed") while (u := goodRed(rec, res, h, b, d, p)) case "failed" repeat p := nextPrime(p::Z)::PI [p, u::UPQ] diff --git a/src/algebra/pgcd.spad.pamphlet b/src/algebra/pgcd.spad.pamphlet index e37aa5d0..c371c1b6 100644 --- a/src/algebra/pgcd.spad.pamphlet +++ b/src/algebra/pgcd.spad.pamphlet @@ -303,6 +303,7 @@ PolynomialGcdPackage(E,OV,R,P):C == T where d:=listpol.first listpol:=listpol.rest nolift:Boolean:=true + uf: SUP for uf in listpol repeat --note uf and d not necessarily primitive degree gcd(uf,d) =0 => nolift:=false diff --git a/src/algebra/polycat.spad.pamphlet b/src/algebra/polycat.spad.pamphlet index 6eef8763..a3232055 100644 --- a/src/algebra/polycat.spad.pamphlet +++ b/src/algebra/polycat.spad.pamphlet @@ -138,6 +138,7 @@ FiniteAbelianMonoidRing(R:Ring, E:OrderedAbelianMonoid): Category == ans,xn,yn: % bincoef: Integer powl: List(%):= [x] + i : Integer for i in 2..nn repeat powl:=[x * powl.first, :powl] yn:=y; ans:=powl.first; i:=1; bincoef:=nn for xn in powl.rest repeat diff --git a/src/algebra/reclos.spad.pamphlet b/src/algebra/reclos.spad.pamphlet index 82687d55..ff396d16 100644 --- a/src/algebra/reclos.spad.pamphlet +++ b/src/algebra/reclos.spad.pamphlet @@ -576,6 +576,8 @@ RightOpenIntervalRootCharacterization(TheField,ThePolDom) : PUB == PRIV where pval := pval rem dPol degree(pval) = 0 => leadingCoefficient(pval) dpval := differentiate(pval) + a : TheField + b : TheField degree(dpval) = 0 => l := left(rootCode) r := right(rootCode) diff --git a/src/algebra/rule.spad.pamphlet b/src/algebra/rule.spad.pamphlet index 98e0ee8d..6b089035 100644 --- a/src/algebra/rule.spad.pamphlet +++ b/src/algebra/rule.spad.pamphlet @@ -242,6 +242,7 @@ ApplyRules(Base, R, F): Exports == Implementation where isit(subject, pat) == hasTopPredicate? pat => + l : List P for v in (l := variables pat) repeat resetBadValues v isitwithpred(subject, pat, l, empty()) patternMatch(subject, pat, new()$PR) diff --git a/src/algebra/sex.spad.pamphlet b/src/algebra/sex.spad.pamphlet index 90fdea78..3e969f92 100644 --- a/src/algebra/sex.spad.pamphlet +++ b/src/algebra/sex.spad.pamphlet @@ -115,6 +115,7 @@ SExpressionOf(Str, Sym, Int, Flt, Expr): Decl == Body where atom? b => coerce(b)$Rep r := b while not atom? r repeat r := cdr r + l : List % l1 := [b1::OutputForm for b1 in (l := destruct b)] not null? r => paren blankSeparate concat_!(l1, [dotex, r::OutputForm]) diff --git a/src/algebra/sgcf.spad.pamphlet b/src/algebra/sgcf.spad.pamphlet index a86554a0..500b92b4 100644 --- a/src/algebra/sgcf.spad.pamphlet +++ b/src/algebra/sgcf.spad.pamphlet @@ -211,6 +211,7 @@ SymmetricGroupCombinatoricFunctions(): public == private where for t in 0..(m-2) repeat s : I := 0 sOld: I + y : I for y in 0..n repeat sOld := s s := s + numberOfImproperPartitions(n-y,m-t-1) @@ -239,6 +240,7 @@ SymmetricGroupCombinatoricFunctions(): public == private where s : I := 0 cm := cm - 1 sOld : I + y : I for y in n..1 by -1 repeat --determination of the next son sOld := s -- remember old s -- this functions counts the number of elements in a subtree @@ -267,6 +269,7 @@ SymmetricGroupCombinatoricFunctions(): public == private where mm : I := k s : I := m for t in 0..(m-1) repeat + y : Integer for y in (s-1)..(n+1) repeat if binomial$ICF (y,s) > mm then leave l := append (l,list(y-1)$(L I)) diff --git a/src/algebra/smith.spad.pamphlet b/src/algebra/smith.spad.pamphlet index dd3ff8ca..fb3c13f6 100644 --- a/src/algebra/smith.spad.pamphlet +++ b/src/algebra/smith.spad.pamphlet @@ -175,7 +175,7 @@ SmithNormalForm(R,Row,Col,M) : Exports == Implementation where mmh:=rowEchelon mm [subMatrix(mmh,1,m1,1,n1), subMatrix(mmh,1,m1,n1+1,n1+m1)] u:M:=zero(m1,m1) - j:=1 + j: Integer :=1 while t(1,j)=0 repeat j:=j+1 -- there are 0 columns t1:=copy t mm:=copy m @@ -187,6 +187,7 @@ SmithNormalForm(R,Row,Col,M) : Exports == Implementation where u(i,1) := (mm(i,1) exquo t11) :: R for j in 2..m1 repeat j0:=j + tjj : R while zero?(tjj:=t1(j,j0)) repeat j0:=j0+1 u(i,j) :=((mm(i,j0) - ("+"/[u(i,k) * t1(k,j0) for k in 1..(j-1)])) exquo tjj) :: R diff --git a/src/algebra/solvelin.spad.pamphlet b/src/algebra/solvelin.spad.pamphlet index 4700ce1a..f3f6a63e 100644 --- a/src/algebra/solvelin.spad.pamphlet +++ b/src/algebra/solvelin.spad.pamphlet @@ -79,6 +79,7 @@ LinearSystemMatrixPackage(F, Row, Col, M): Cat == Capsule where -- find leading elements of diagonal v := new(nvar, minRowIndex m - 1)$PrimitiveArray(Integer) for i in minRowIndex m .. rk repeat + j : Integer for j in 0.. while zero? qelt(m, i, j+minColIndex m) repeat 0 v.j := i for j in 0..nvar-1 repeat diff --git a/src/algebra/string.spad.pamphlet b/src/algebra/string.spad.pamphlet index 09adfaf7..d5b13181 100644 --- a/src/algebra/string.spad.pamphlet +++ b/src/algebra/string.spad.pamphlet @@ -468,6 +468,7 @@ IndexedString(mn:Integer): Export == Implementation where h:I := if hasHi sg then hi(sg) - mn else maxIndex s - mn l < 0 or h >= m or h < l-1 => error "index out of range" r := new((m-(h-l+1)+n)::N, space$C) + k : NonNegativeInteger for k in 0.. for i in 0..l-1 repeat Qsetelt(r, k, Qelt(s, i)) for k in k.. for i in 0..n-1 repeat Qsetelt(r, k, Qelt(t, i)) for k in k.. for i in h+1..m-1 repeat Qsetelt(r, k, Qelt(s, i)) @@ -512,6 +513,7 @@ IndexedString(mn:Integer): Export == Implementation where split(s, c) == n := maxIndex s + i : NonNegativeInteger for i in mn..n while s.i = c repeat 0 l := empty()$List(%) j:Integer -- j is conditionally intialized @@ -520,8 +522,10 @@ IndexedString(mn:Integer): Export == Implementation where for i in j..n while s.i = c repeat 0 if i <= n then l := concat(s(i..n), l) reverse_! l + split(s, cc) == n := maxIndex s + i : NonNegativeInteger for i in mn..n while member?(s.i,cc) repeat 0 l := empty()$List(%) j:Integer -- j is conditionally intialized @@ -533,17 +537,23 @@ IndexedString(mn:Integer): Export == Implementation where leftTrim(s, c) == n := maxIndex s + i : NonNegativeInteger for i in mn .. n while s.i = c repeat 0 s(i..n) + leftTrim(s, cc) == n := maxIndex s + i : NonNegativeInteger for i in mn .. n while member?(s.i,cc) repeat 0 s(i..n) rightTrim(s, c) == + j : NonNegativeInteger for j in maxIndex s .. mn by -1 while s.j = c repeat 0 s(minIndex(s)..j) + rightTrim(s, cc) == + j : NonNegativeInteger for j in maxIndex s .. mn by -1 while member?(s.j, cc) repeat 0 s(minIndex(s)..j) diff --git a/src/algebra/syssolp.spad.pamphlet b/src/algebra/syssolp.spad.pamphlet index ef019257..88f7b334 100644 --- a/src/algebra/syssolp.spad.pamphlet +++ b/src/algebra/syssolp.spad.pamphlet @@ -118,6 +118,7 @@ SystemSolvePackage(R): Cat == Cap where z:=last lv np:=numer makeP2F p lx:=variables np + x : SE for x in lv repeat if member?(x,lx) then leave x up:=univariate(np,x) (degree up)=1 => diff --git a/src/algebra/view2D.spad.pamphlet b/src/algebra/view2D.spad.pamphlet index a318364c..dfab772f 100644 --- a/src/algebra/view2D.spad.pamphlet +++ b/src/algebra/view2D.spad.pamphlet @@ -366,8 +366,9 @@ GraphImage (): Exports == Implementation where graphImage == graph [] makeGraphImage(llp) == + l := #llp makeGraphImage(llp, - [pointColorDefault() for i in 1..(l:=#llp)], + [pointColorDefault() for i in 1..l], [lineColorDefault() for i in 1..l], [pointSizeDefault() for i in 1..l]) @@ -406,8 +407,9 @@ GraphImage (): Exports == Implementation where component(graf,aPoint,PointColor,lineColorDefault(),pointSizeDefault()) coerce (llp : L L P) : $ == + l := #llp makeGraphImage(llp, - [pointColorDefault() for i in 1..(l:=#llp)], + [pointColorDefault() for i in 1..l], [lineColorDefault() for i in 1..l], [pointSizeDefault() for i in 1..l]) diff --git a/src/algebra/wtpol.spad.pamphlet b/src/algebra/wtpol.spad.pamphlet index af1414e0..7f64a69f 100644 --- a/src/algebra/wtpol.spad.pamphlet +++ b/src/algebra/wtpol.spad.pamphlet @@ -59,7 +59,7 @@ WeightedPolynomials(R:Ring,VarSet: OrderedSet, E:OrderedAbelianMonoidSup, lookupList:=[[v,n] for v in vl for n in wl] -- local operation innercoerce:(p,z) -> $ - lookup:Varset -> NonNegativeInteger + lookup:VarSet -> NonNegativeInteger lookup v == l:=lookupList while l ~= [] repeat diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot index a8475327..a2691741 100644 --- a/src/interp/c-util.boot +++ b/src/interp/c-util.boot @@ -512,7 +512,9 @@ unStackWarning(msg,args) == nil stackMessage(msg,args == nil) == - $compErrorMessageStack:= [buildMessage(msg,args),:$compErrorMessageStack] + if args ^= nil then + msg := buildMessage(msg,args) + $compErrorMessageStack:= [msg,:$compErrorMessageStack] nil stackMessageIfNone msg == diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot index b120fc9d..397e6b9a 100644 --- a/src/interp/compiler.boot +++ b/src/interp/compiler.boot @@ -563,7 +563,7 @@ eltModemapFilter(name,mmList,e) == isConstantId(name,e) => l:= [mm for mm in mmList | mm is [[.,.,.,sel,:.],:.] and sel=name] => l --there are elts with extra parameters - stackMessage('"selector variable: %1 is undeclared and unbound",[name]) + stackMessage('"selector variable: %1b is undeclared and unbound",[name]) nil mmList @@ -571,7 +571,7 @@ seteltModemapFilter(name,mmList,e) == isConstantId(name,e) => l:= [mm for (mm:= [[.,.,.,sel,:.],:.]) in mmList | sel=name] => l --there are setelts with extra parameters - stackMessage('"selector variable: %1 is undeclared and unbound",[name]) + stackMessage('"selector variable: %1b is undeclared and unbound",[name]) nil mmList @@ -727,7 +727,7 @@ setqMultiple(nameList,val,m,e) == [[name,:mode] for [":",name,mode] in l] stackMessage('"no multiple assigns to mode: %1p",[t]) #nameList^=#selectorModePairs => - stackMessage('"%1 must decompose into %2 components",[val,#nameList]) + stackMessage('"%1b must decompose into %2 components",[val,#nameList]) 3 --generate code; return assignList:= [([.,.,e]:= compSetq1(x,["elt",g,y],z,e) or return "failed").expr @@ -737,7 +737,7 @@ setqMultiple(nameList,val,m,e) == setqMultipleExplicit(nameList,valList,m,e) == #nameList^=#valList => - stackMessage('"Multiple assignment error; # of items in: %1 must = # in: %2",[nameList,valList]) + stackMessage('"Multiple assignment error; # of items in: %1b must = # in: %2",[nameList,valList]) gensymList:= [genVariable() for name in nameList] assignList:= --should be fixed to declare genVar when possible diff --git a/src/interp/iterator.boot b/src/interp/iterator.boot index d62f4939..19ead302 100644 --- a/src/interp/iterator.boot +++ b/src/interp/iterator.boot @@ -45,10 +45,11 @@ compReduce1(form is ["REDUCE",op,.,collectForm],m,e,$formalArgList) == if STRINGP op then op:= INTERN op ^MEMQ(collectOp,'(COLLECT COLLECTV COLLECTVEC)) => systemError ["illegal reduction form:",form] - $sideEffectsList: local - $until: local - $initList: local - $endTestList: local + $sideEffectsList: local := nil + $until: local := nil + $initList: local := nil + $endTestList: local := nil + oldEnv := e $e:= e itl:= [([.,$e]:= compIterator(x,$e) or return "failed").(0) for x in itl] itl="failed" => return nil @@ -73,7 +74,7 @@ compReduce1(form is ["REDUCE",op,.,collectForm],m,e,$formalArgList) == if $until then [untilCode,.,e]:= comp($until,$Boolean,e) finalCode:= substitute(["UNTIL",untilCode],'$until,finalCode) - [finalCode,m,e] + [finalCode,m,oldEnv] ++ returns the identity element of the `reduction' operation `x' ++ over a list -- a monoid homomorphism. @@ -93,6 +94,7 @@ compRepeatOrCollect(form,m,e) == ,e) where fn(form,$exitModeStack,$leaveLevelStack,$formalArgList,e) == $until: local + oldEnv := e [repeatOrCollect,:itl,body]:= form itl':= [([x',e]:= compIterator(x,e) or return "failed"; x') for x in itl] @@ -135,7 +137,7 @@ compRepeatOrCollect(form,m,e) == T := coerceExit([form',m'',e'],targetMode) or return nil -- iterator variables and other variables declared in -- in a loop are local to the loop. - [T.expr,T.mode,e] + [T.expr,T.mode,oldEnv] --constructByModemap([x,source,e],target) == -- u:= @@ -213,7 +215,7 @@ compIterator(it,e) == it is ["WHILE",p] => [p',m,e]:= comp(p,$Boolean,e) or return - stackMessage('"WHILE operand: %1 is not Boolean valued",[p]) + stackMessage('"WHILE operand: %1b is not Boolean valued",[p]) [["WHILE",p'],e] it is ["UNTIL",p] => ($until:= p; ['$until,e]) it is ["|",x] => |