[
and ]
) are allowed. Fortunately or unfortunately, the
a68toc compiler flags this as an error.
2.0
in
the row-display cannot be coerced to a value of mode INT
in a
strong context (or any context, for that matter).
[]INT first 4 odd numbers = (1,3,5,7)
8
1
3
1 LWB a
, 1 UPB a
, 2 LWB a
,
2 UPB a
, 3 LWB a
,
LWB b
, UPB b
6
(9,10,11,12)
(4,8,12,16)
r[3,2]
r[2,]
r[,3]
[][]CHAR months= ("January","February","March", "April","May","June", "July","August","September", "October","November","December")
30
(0.0,-5.4)
11.4
(6,7,8)
"pqrst"
PROGRAM ex3 9 CONTEXT VOID USE standard BEGIN [,]INT m = ((1,2,3,4),(5,6,7,8), (9,10,11,12),(13,14,15,16)); print(("m[2,2]=",m[2,2],newline, "m[3,]=",m[3,],newline, "m[,2 UPB m]=",m[,2 UPB m], newline)) END FINISH
Man bites dog
bbbii
PROGRAM ex3 11 CONTEXT VOID USE standard BEGIN FOR num TO 25 DO print((num^3,newline)) OD END FINISH
PROGRAM ex3 12 CONTEXT VOID USE standard BEGIN FOR c FROM ABS "Z" BY -1 TO ABS "A" DO print(REPR c) OD END FINISH
REPR
:-
PROGRAM ex3 13a CONTEXT VOID USE standard BEGIN FOR row TO 5 DO FOR letter TO 4 DO print((REPR((row-1)*5 +letter+ABS"@"),",") OD; print((REPR(row*5 + ABS "@"), newline)) OD END FINISHThe second solution uses an actual alphabet and a modified inner loop. Note that the formulæ in the
FROM
and TO
constructs are elaborated once only: before the inner loop is
elaborated for the first time in each elaboration of the outer loop:-
PROGRAM ex3 13b CONTEXT VOID USE standard BEGIN []CHAR alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[@1]; FOR row TO 5 DO INT row5 = row*5; FOR letter FROM row5-4 TO row5-1 DO print((alphabet[letter],",")) OD; print((alphabet[row5],newline)) OD END FINISH
print
will quite happily take the 3-dimensional multiple as
its parameter:
PROGRAM ex3 14 CONTEXT VOID USE standard BEGIN [,,]REAL m=(((1e-7,1e-6), (1e-5,1e-4)), ((1e-3,1e-2), (1e-1,1.0))); print(m) END FINISH
[1:2,1:3]
[1:3]
[1:2]
(6,5,4)
[]INT
(8,5,2)
[]INT
(7,4)
[]INT
((6,5),(3,2))
[,]INT
"abcabcabcdefg"
BY
:
PROGRAM ex3 18 CONTEXT VOID USE standard BEGIN []CHAR alphabet = "abcdefghijklmnopqrstuvwxyz"; []INT by = (1,6,11,16,21,26); FOR c BY --5 TO UPB alphabet DO print(alphabet[c]) OD END FINISH
Sian Mountbatten 2012-01-19