代码中的一些提示可能会有所帮助,并且TiO-IDE的礼貌可能会为在线实验提供一个场所:
#INCLUDE "course.module"
PROC main( CHAN BYTE keyboard, screen, error )
[32]INT x:
INT aux:
BOOL flag:
SEQ -- ------------------------- BoSEQ:
SEQ i = 0 FOR 31 -- SEQ used as <-an-iterator->
x[i] := i -- put values on the array
SEQ i = 0 FOR 10 -- SEQ used as <-an-iterator->
x[i] := -x[i] -- put values on the array
flag := TRUE
WHILE ( flag ) -- WHILE
SEQ -- SEQ as a bubble sort
SEQ i = 0 FOR 10 -- SEQ used as <-an-iterator->
IF -- IF
x[i] > x[i+1] -- CASE: x[i] > x[i+1]
SEQ -- SEQ of steps
aux := x[i] -- 1
x[i] := x[i+1] -- 2
x[i+1] := aux -- 3
-- -- -- -- -- -- -- -- -- -- -- -- -- --
-- INTERESTING [occam-pi] FEATURE IS, THAT
-- [occam-pi] CAN _SWAP_ IN-PLACE
-- USING JUST x[i], x[i+1] := x[i+1], x[i]
TRUE -- OTHERWISE:
SKIP
-- SEQ used above as <-an-iterator-> got exhausted
flag := FALSE -- SET FALSE
-- ----------------------------- EoSEQ:
: -- main()