



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
declare MyGauge = {NewGauge} {Test local R in {Send MyGauge fetch(R)} R end ’==’ 0} {Send MyGauge up} {Test {Send MyGauge fetch($)} ’==’ 1} {Send MyGauge up} {Test {Send MyGauge fetch($)} ’==’ 2} {Send MyGauge down} {Test {Send MyGauge fetch($)} ’==’ 1} {Send MyGauge up} {Send MyGauge up} {Test {Send MyGauge fetch($)} ’==’ 3}
MyGauge2 = {NewGauge} {Test {Send MyGauge2 fetch($)} ’==’ 0} {Send MyGauge2 down} {Test {Send MyGauge2 fetch($)} ’==’ ~1} {Send MyGauge2 down} {Test {Send MyGauge2 fetch($)} ’==’ ~2} for I in 1..12 do {Send MyGauge2 up} end {Test {Send MyGauge2 fetch($)} ’==’ 10}
declare MyAer = {NewAuctioneer} local Status1 Status2 Status3 Status4 in {Send MyAer bid(17 Status1)} {Send MyAer bid(8 Status2)} {Send MyAer bid(27 Status3)} {Send MyAer bid(24 Status4)} {Send MyAer stop} {Test Status1 ’==’ false } {Test Status2 ’==’ false } {Test Status3 ’==’ true } {Test Status4 ’==’ false } end
MyAer2 = {NewAuctioneer} local Status1 Status2 Status3 Status Status5 Status6 Status in {Send MyAer2 bid(100 Status1)} {Send MyAer2 bid(15 Status2)} {Send MyAer2 bid(99 Status3)} {Send MyAer2 bid(99 Status4)} {Send MyAer2 bid(100 Status5)} {Send MyAer2 bid(100 Status6)} {Send MyAer2 bid(100 Status7)} {Send MyAer2 stop} % first of the highest bids wins {Test Status1 ’==’ true } {Test Status2 ’==’ false } {Test Status3 ’==’ false } {Test Status4 ’==’ false } {Test Status5 ’==’ false } {Test Status6 ’==’ false } {Test Status7 ’==’ false } end
% Stopping with no bids MyAer3 = {NewAuctioneer} {Send MyAer3 stop} % Bidding after an auction is over {Test {Send MyAer3 bid(50 $)} ’==’ false }
{Test {SolveAll proc {$ Ans} {PositionOf nil 0 Ans} end } ’==’ nil} {Test {SolveAll proc {$ Ans} {PositionOf 0|nil 0 Ans} end } ’==’ [1]} {Test {SolveFirst proc {$ Ans} {PositionOf [4 0 2 0] 4 Ans} end } ’==’ 1} {Test {SolveAll proc {$ Ans} {PositionOf [4 0 2 0] 0 Ans} end } ’==’ [2 4]} {Test {SolveFirst proc {$ Ans} {PositionOf [4 0 2 0] 2 Ans} end } ’==’ 3} {Test {SolveAll proc {$ Ans} {PositionOf [4 0 2 0] 5 Ans} end } ’==’ nil} {Test {SolveAll proc {$ Ans} {PositionOf [5 0 2 1 4 0 2 0 88] 0 Ans} end } ’==’ [2 6 8]} {Test {SolveFirst proc {$ X} {PositionOf [99 22 X 55] 7 3} end } ’==’ 7} {Test {SolveFirst proc {$ Ind} {PositionOf [99 22 8 55] Ind 3} end } ’==’ 8}