
obj1:= @length[{a,b,c,d,e}];
tst1:= 5 - @(obj1);
@collect_terms!(%);
@assert(tst1);

obj2:= @range[{-3,4}];
tst2:= {-3,-2,-1,0,1,2,3,4} - @(obj2);
@collect_terms!(%);
@assert(tst2);

obj3:= @inner[{ @range[{0,4}], @range[{-1,3}] }];
tst3:= 2+6+12 - @(obj3);
@collect_terms!(%);
@assert(tst3);

obj4a:= {a_m, b_m ,c_m ,d_m ,e_m };
obj4b:= @range[{1, @length[@(obj4a)]}];
obj4c:= @inner[ { @(obj4a), @(obj4b) } ];
tst4:= a_m + 2 b_m + 3 c_m + 4 d_m + 5 e_m - @(obj4c);
@collect_terms!(%);
@assert(tst4);

obj5a:= {a,b,c,d,e};
obj5b:= @range[{i, 1, @length[@(obj5a)], c_{i} }];
tst5:= { c_1, c_2, c_3, c_4, c_5 }  - @(obj5b);
@collect_terms!(%);
@assert(tst5);

obj6:= @range[{1, 5, c}];
tst6:= {c,c,c,c,c} - @(obj6);
@collect_terms!(%);
@assert(tst6);

# This also works, because curly brackets are b_none:
#
obj6b:= @range[1, 5, c];
tst6b:= {c,c,c,c,c} - @(obj6b);
@collect_terms!(%);
@assert(tst6b);

# obj7:= @range[{i, 1, 10, i/(i-1)*c_{i} }];

# Test 8: List addition.
#
@reset.
obj8:= {a, b, 7 c + q, d, e} - {-f, g, h, i, j};
@list_sum!(%);
@sumflatten!(%);
tst8:= {a + f, b - g, 7c + q - h, d - i, e - j} - @(obj8);
@collect_terms!(%);
@assert(tst8);

# Test 9: Take
#
@reset;
obj9:= A_{m n} + B_{m n} + C_{m} * D_{n} + E_{m n p} * Q_{p};
@take(%){2,3};
tst9a:= C_{m} * D_{n} + E_{m n p} * Q_{p} - @(obj9);
@collect_terms!(%);
@assert(tst9a);

@pop(obj9);
@take(%){2..\infty};
tst9b:= C_{m} * D_{n} + E_{m n p} * Q_{p} - @(obj9);
@collect_terms!(%);
@assert(tst9b);

@pop(obj9);
@take(%){1};
tst9c:= B_{m n} - @(obj9);
@collect_terms!(%);
@assert(tst9c);
