



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The instructions and problems for a spring 2008 university test in the cop 4020 - programming languages 1 course. The test covers topics such as the demand-driven concurrent model, message passing, and the relational model in oz programming language. Students are required to write functions using these models and answer conceptual questions.
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!




For Grading
declare % UpFrom is a helper for testing purposes fun lazy {UpFrom N} N|{UpFrom N+1} end
{Test {List.take {TempDiff {UpFrom 0} 25} 7} ’==’ [~25 ~24 ~23 ~22 ~21 ~20 ~19]} {Test {List.take {TempDiff {UpFrom 23} 25} 7} ’==’ [~2 ~1 0 1 2 3 4]} {Test {List.take {TempDiff {Append [5 30 26 26] {UpFrom 23}} 25} 7} ’==’ [~20 5 1 1 ~2 ~1 0]}
declare % The following are helper functions, for testing purposes fun lazy {DownFrom N} N|{DownFrom N-1} end fun lazy {Steady N} N|{Steady N} end
{Test {List.take {HeatControl {DownFrom 0} 3} 8} ’==’ [0 0 0 0 2 2 3 3]} {Test {List.take {HeatControl {Steady ~2} 3} 7} ’==’ [0 0 0 0 0 0 0]} {Test {List.take {HeatControl {Steady ~3} 3} 7} ’==’ [0 0 0 0 0 0 0]} {Test {List.take {HeatControl {Steady ~4} 3} 7} ’==’ [2 2 2 2 2 2 2]} {Test {List.take {HeatControl {DownFrom ~18} 3} 7} ’==’ [9 9 10 10 10 10 10]} {Test {List.take {HeatControl {Append [0 ~3 ~2 ~3 ~4 ~2 ~3] {DownFrom ~5}} 3} 8} ’==’ [0 0 0 0 2 1 1 2]} {Test {List.take {HeatControl {DownFrom 3} 4} 11} ’==’ [0 0 0 0 0 0 0 0 2 3 3]} {Test {List.take {HeatControl {Append [5 30 26 26] {DownFrom 2}} 1} 11} ’==’ [0 0 0 0 0 0 0 0 1 1 2]}
declare local Commands Heater Thermo in Heater = {NewPort Commands} Thermo = {NewThermostat Heater} {Test {List.take Commands 1} ’==’ [run(0)]} {Send Thermo currentReading(78)} {Test {List.take Commands 2} ’==’ [run(0) run(0)]} {Send Thermo currentReading(77)} {Test {List.take Commands 3} ’==’ [run(0) run(0) run(1)]} {Send Thermo currentReading(70)} {Test {Nth Commands 4} ’==’ run(5)} {Send Thermo setPoint(72)} {Test {Nth Commands 5} ’==’ run(1)} {Send Thermo currentReading(68)} {Test {Nth Commands 6} ’==’ run(2)} {Send Thermo currentReading(71)} {Test {Nth Commands 7} ’==’ run(0)} {Send Thermo currentReading(70)} {Test {Nth Commands 8} ’==’ run(0)} end % More examples on the next page...