





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






For Grading
MyFun = proc {$ Work Elems Ret} local Z in local MyFun in MyFun = proc {$ X R} Y={Times X X} end {FoldR Elems MyFun Z} {Apply Work Z Ret} end end end
MyFun = proc {$ Work Elems Ret} local Z in local MyFun in MyFun = proc {$ X R} Y={Times X X} end {FoldR Elems MyFun Z} {Apply Work Z Ret} end end end
{Test {TeamSpirit nil} ’==’ nil} {Test {TeamSpirit [ncstate]} ’==’ [[beat ncstate]]} {Test {TeamSpirit [texas ncstate]} ’==’ [[beat texas] [beat ncstate]]} {Test {TeamSpirit [louisiana texas ncstate]} ’==’ [[beat louisiana] [beat texas] [beat ncstate]]} {Test {TeamSpirit [smiss tulsa usf ecarolina louisiana texas ncstate]} ’==’ [[beat smiss] [beat tulsa] [beat usf] [beat ecarolina] [beat louisiana] [beat texas] [beat ncstate]]}
{Test {MinElement [3]} ’==’ 3} {Test {MinElement [4020]} ’==’ 4020} {Test {MinElement [7 19]} ’==’ 7} {Test {MinElement [3 7 19]} ’==’ 3} {Test {MinElement [54 3 7 19]} ’==’ 3} {Test {MinElement [78 7 654 7 5 54 3 7 19]} ’==’ 3} {Test {MinElement [~6 78 7 654 7 5 54 3 7 19]} ’==’ ~6}
declare fun {StdEnv Str} case Str of "One" then 1 [] "Two" then 2 [] "Ten" then 10 [] "Z" then 0 else raise stdEnvIsUndefinedOn(Str) end end end
{Test {EvalExp varIdExp("Two") StdEnv} ’==’ 2} {Test {EvalExp varIdExp("One") StdEnv} ’==’ 1} {Test {EvalExp varIdExp("One") fun {$ N} 7 end } ’==’ 7} {Test {EvalExp numExp(20) StdEnv} ’==’ 20} {Test {EvalExp plusExp(varIdExp("Two") numExp(20)) StdEnv} ’==’ 22} {Test {EvalExp timesExp(varIdExp("Two") numExp(20)) StdEnv} ’==’ 40}
{Test {EvalExp timesExp(numExp(7) plusExp(varIdExp("Ten") numExp(1))) StdEnv} ’==’ 77}
{Test {EvalExp plusExp(timesExp(varIdExp("Two") plusExp(varIdExp("Ten") varIdExp("Z"))) plusExp(varIdExp("Two") varIdExp("One"))) StdEnv} ’==’ 23}
{Test {EvalExp plusExp( plusExp(timesExp(varIdExp("Two") plusExp(varIdExp("Ten") varIdExp("Z"))) plusExp(varIdExp("Two") varIdExp("One"))) timesExp(numExp(7) plusExp(varIdExp("Ten") numExp(1)))) StdEnv} ’==’ 100}