File size: 788 Bytes
497f2f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
( 100doors-tbl
=   door step
  .   tbl$(doors.101) { Create an array. Indexing is 0-based. Add one extra for addressing element nr. 100 }
    & 0:?step
    &   whl
      ' ( 1+!step:~>100:?step   { ~> means 'not greater than', i.e. 'less than or equal' }
        & 0:?door
        &   whl
          ' ( !step+!door:~>100:?door
            & 1+-1*!(!door$doors):?doors  { <number>$<variable> sets the current index, which stays the same until explicitly changed. }
            )
        )
    & 0:?door
    &   whl
      ' ( 1+!door:~>100:?door
        &   out
          $ ( door
              !door
              is
              ( !(!door$doors):1&open
              | closed
              )
            )
        )
    & tbl$(doors.0)  { clean up the array }
)