From a88fca4f495ba4f9d3d1341d5da65f4813cb9ddf Mon Sep 17 00:00:00 2001 From: Mahrud Sayrafi Date: Tue, 27 Aug 2024 02:08:04 +0200 Subject: [PATCH] simplified evaluation of semiCode in evaluate.d --- M2/Macaulay2/d/evaluate.d | 62 ++++++++++++--------------------------- 1 file changed, 18 insertions(+), 44 deletions(-) diff --git a/M2/Macaulay2/d/evaluate.d b/M2/Macaulay2/d/evaluate.d index 9f2ef7cfba..873de0b420 100644 --- a/M2/Macaulay2/d/evaluate.d +++ b/M2/Macaulay2/d/evaluate.d @@ -48,28 +48,15 @@ export evalAllButTail(c:Code):Code := while true do c = ( else ( return Code(Error(codePosition(i.predicate),"expected true or false",nullE,false,dummyFrame)); dummyCode)) - is v:semiCode do ( - w := v.w; - n := length(w); -- at least 2 - r := eval(w.0); - when r is e:Error do return Code(e) else nothing; - if n == 2 then w.1 else ( - r = eval(w.1); - when r is e:Error do return Code(e) else nothing; - if n == 3 then w.2 else ( - r = eval(w.2); - when r is e:Error do return Code(e) else nothing; - if n == 4 then w.3 else ( - r = eval(w.3); - when r is e:Error do return Code(e) else nothing; - if n == 5 then w.4 else ( - r = eval(w.4); - when r is e:Error do return Code(e) else nothing; - i := 5; - while i < n-1 do ( - r = eval(w.i); - when r is e:Error do return Code(e) else i = i+1); - w.i))))) + is v:semiCode do ( + i := 0; + w := v.w; + n := length(w); -- at least 2 + r := nullE; + while i < n-1 do ( + r = eval(w.i); + when r is e:Error do return Code(e) else i = i+1); + w.i) else ( return c; dummyCode)); @@ -1510,28 +1497,15 @@ export evalraw(c:Code):Expr := ( is v:integerCode do return Expr(ZZcell(v.x)) is v:stringCode do return Expr(stringCell(v.x)) is v:Error do Expr(v) - is v:semiCode do ( - w := v.w; - n := length(w); -- at least 2 - r := eval(w.0); - when r is Error do r else ( - r = eval(w.1); - when r is Error do r else ( - if n == 2 then return r; - r = eval(w.2); - when r is Error do r else ( - if n == 3 then return r; - r = eval(w.3); - when r is Error do r else ( - if n == 4 then return r; - r = eval(w.4); - when r is Error do r else ( - i := 5; - while i < n do ( - r = eval(w.i); - i = when r is Error do n else i+1; - ); - r)))))) + is v:semiCode do ( + i := 0; + w := v.w; + n := length(w); -- at least 2 + r := nullE; + while i < n do ( + r = eval(w.i); + i = when r is Error do n else i+1); + r) is v:sequenceCode do ( if length(v.x) == 0 then return emptySequence; r := evalSequence(v.x);