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}{:=}\left[{1}{\,}{3}{\,}{5}\right]$
 (1) 
This is not the case for Arrays.
${}$
>

a := Array(1 .. 5, {1 = 1, 2 = NULL, 3 = 3, 4 = NULL, 5 = 5});

${a}{:=}\left[\begin{array}{ccccc}{1}& {\mathrm{NULL}}& {3}& {\mathrm{NULL}}& {5}\end{array}\right]$
 (2) 
This paradigm was mirrored in selectremove.
>

select(isprime, [1, 2, 3, 4, 5, 6]);

$\left[{2}{\,}{3}{\,}{5}\right]$
 (3) 
>

select(isprime, <1, 2, 3, 4, 5, 6>);

$\left[\begin{array}{c}{\mathrm{NULL}}\\ {2}\\ {3}\\ {\mathrm{NULL}}\\ {5}\\ {\mathrm{NULL}}\end{array}\right]$
 (4) 
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>);

$\left[\begin{array}{r}{2}\\ {3}\\ {5}\end{array}\right]$
 (5) 
>

remove[flatten](isprime, table({1 = 1, 2 = 2, 3 = 3, 4 = 4, 5 = 5, 6 = 6}));

${\mathrm{table}}\left(\left[{1}{\=}{1}{\,}{4}{\=}{4}{\,}{6}{\=}{6}\right]\right)$
 (6) 
${}$
Multidimensional data is flattened into a onedimensional array.
>

M := <1, 2, 3; 4, 5, 6>;

${M}{:=}\left[\begin{array}{rrr}{1}& {2}& {3}\\ {4}& {5}& {6}\end{array}\right]$
 (7) 
>

select[flatten](isprime, M);

$\left[\begin{array}{ccc}{2}& {5}& {3}\end{array}\right]$
 (8) 
>

remove[flatten](isprime, M);

$\left[\begin{array}{ccc}{1}& {4}& {6}\end{array}\right]$
 (9) 
>

selectremove[flatten](isprime, M);

$\left[\begin{array}{ccc}{2}& {5}& {3}\end{array}\right]{\,}\left[\begin{array}{ccc}{1}& {4}& {6}\end{array}\right]$
 (10) 
${}$
${}$
