# PDCO # # Programmer-defined control operations # # Ralph E. Griswold and Michael Novak # # Last modified 8/11/84 # procedure Alt(a) local x while x := @a[1] do suspend x while x := @a[2] do suspend x end procedure Colseq(a) suspend |@!a end procedure Comseq(a) local x1, x2 while x1 := @a[1] do (x1 === @a[2]) | fail if @a[2] then fail else return *a[1] end procedure Cond(a) local i, x every i := 1 to *a do if x := @a[i] then { suspend x suspend |@a[i] fail } end procedure Every(a) while @a[1] do @^a[2] end procedure Galt(a) local e every e := !a do suspend |@e end procedure Lcond(a) local i every i := 1 to *a by 2 do if @a[i] then { suspend |@a[i + 1] fail } end procedure Limit(a) local i, x while i := @a[2] do { a[1] := ^a[1] every 1 to i do if x := @a[1] then suspend x else break } end procedure Ranseq(a) local x while x := @?a do suspend x end procedure Repalt(a) local x repeat { while x := @a[1] do suspend x if *a[1] = 0 then fail else a[1] := ^a[1] } end procedure Resume(a) local i while i := @a[2] do { a[1] := ^a[1] every 1 to i do if @a[1] then @^a[3] else break } end procedure Select(a) local i, j, x j := 0 while i := @a[2] do { while j < i do if x := @a[1] then j +:= 1 else fail if i = j then suspend x else stop("selection sequence error") } end