Function: flatten - entries of a structure involving lists, sets, or arrays

Calling sequence:
flatten(expr);

Parameters:

expr - the expression

Description:

Examples:

> flatten([{{a,b},{c,d}}]);

a, b, c, d

> M:= matrix([[1,2],[3,2]]);

M := matrix([[1, 2], [3, 2]])

> flatten(M);

1, 2, 3, 2

> Q:= array(1..2,1..2,1..2,[[[1,2],[3,4]],[[5,6],[7,8]]]):

> flatten(Q);

1, 2, 3, 4, 5, 6, 7, 8

> flatten(Matrix(M));

1, 2, 3, 2

> flatten(Array(Q));

1, 2, 3, 4, 5, 6, 7, 8

In the following example, T is implicitly constructed as a table by assigning values to its elements. Note that convert(T, list) might not return the entries in the order of the indices, but flatten(T) does.

> T[1]:= first: T[3]:= third: T[2]:= second:

> convert(T,list);

[first, second, third]

> flatten(T);

first, second, third

See also:

array , convert(list) , list , rtable , set , table

Maple Advisor Database R. Israel 1998