if ?get ('amatrix, 'present) = false then load (amatrix) else 'already_loaded;

"... Hilbert matrix ..."$

foo : make_matrix (7, 5)$
for i thru foo@nr do for j thru foo@nc do foo [i, j] : 1/(i + j - 1);
foo;

"... Integer subscripts ..."$

foo [1, 1];

foo [1, 1] : 42;

foo;

"... 'all subscripts ..."$

foo [all, 1];
foo [1, all];

foo [all, all];

bar : foo [all, 1];

mumble : foo [1, all];

"... Collective assignment ..."$

foo [all, 2] : %pi;

foo;

foo [all, 5] : foo [all, 1];

foo;

"... Implicit subscript=1 when #rows=1 or #columns=1 ..."$

bar;

bar [1];

bar [all];

"... Copy-on-write policy ..."$

bar [1];

bar [1] : 1729;

bar;

mumble;

"... List of integers subscripts ..."$

foo [[1, 5, 3], 1];

foo [all, [5, 4, 3]];

foo [[5, 6, 7], [2, 5]];

"... amatrix of Boolean values subscripts ..."$

baz : amatrixmap (lambda ([x], is (x > 3/10)), bar);

quux : amatrixmap (lambda ([x], is (x < 1/4)), bar);

blurf : amatrixmap (lambda ([x], is (x < 1/2)), mumble);

snort : amatrixmap (lambda ([x], is (x >= 1/3)), mumble);

foo [baz, 4];

foo [6, blurf];

foo [baz, all];

foo [all, blurf];

foo [baz, [1, 5]];

foo [[2, 3, 6], blurf];

foo [baz, blurf];

"... Relational expressions subscripts ..."$

bar;

bar [bar > 2/3];

foo [bar >= 1/4, 4];

foo [6, 3/4 >= mumble];

foo [bar > 1/2, all];

foo [all, mumble < 1/2];

foo [bar # 1/2, [5, 2]];

foo [[4, 3, 2], mumble < 3/7];

foo [bar <= 7/8, blurf];

foo [baz, mumble > 1/8];

foo [bar > 2/7, 8/9 >= mumble];

"... Boolean expressions subscripts ..."$

foo [not baz, 3];

foo [7, blurf and snort];

foo [baz and not quux, all];

foo [all, not blurf or snort];

foo [baz or quux, [1, 2, 4]];

foo [[3, 2, 5], not blurf and snort];

foo [quux and baz, snort];

foo [quux, not blurf];

foo [not quux and not baz, mumble < 0.95];

foo [bar > 0.15, not blurf or not snort];

foo [quux or baz, blurf or not snort];


