Selecting Items From an Array or Table
The select, remove, and selectremove commands are ideal for searching for data. The default behaviour of these commands is to return a result object of exactly the same size and dimensions as the one you passed in, with NULL's in place of removed items. Automatic flattening of NULLs makes the behaviour different in lists compared to Arrays.
NULL is automatically removed from lists.
l := [1, NULL, 3, NULL, 5];
l:=1,3,5
This is not the case for Arrays.
a := Array(1 .. 5, {1 = 1, 2 = NULL, 3 = 3, 4 = NULL, 5 = 5});
This paradigm was mirrored in selectremove.
select(isprime, [1, 2, 3, 4, 5, 6]);
2,3,5
select(isprime, <1, 2, 3, 4, 5, 6>);
Now, in Maple 17, you can use an option to force the removal of NULL from arrays and tables. The option, flatten, is noted in square brackets after the command name.
select[flatten](isprime, < 1, 2, 3, 4, 5, 6>);
remove[flatten](isprime, table({1 = 1, 2 = 2, 3 = 3, 4 = 4, 5 = 5, 6 = 6}));
table1=1,4=4,6=6
Multi-dimensional data is flattened into a one-dimensional array.
M := <1, 2, 3; 4, 5, 6>;
select[flatten](isprime, M);
remove[flatten](isprime, M);
selectremove[flatten](isprime, M);
See Also
remove, select, selectremove
Download Help Document