list - Maple Help

# Online Help

###### All Products    Maple    MapleSim

convert/list

 Calling Sequence convert( expr, list, expected_type ) convert( expr, list, nested_op )

Parameters

 expr - expression to convert expected_type - (optional) +, *, or ^ nested_op - (optional) option of the form nested=true or false; whether to preserve structure of rtables and arrays

Description

 • This command can be used to convert a variety of expressions into list form.  The precise form of the result is determined by the input and the nested_op and expected_type options.
 • The use of the expected_type option enables the convenient extraction of terms, factors or (base, exponent) pairs without worrying about the trivial cases. If expected_type is given and expr is not of type expected_type, expr is interpreted trivially to be of that type: a sum of one term, a product of one factor, or a power with exponent 1. The return value is [expr, 1] if expected_type=^, and [expr] otherwise.
 • The nested_op option is only relevant if the input expr is an rtable (Matrix, Array, or Vector) or array, matrix, or vector.

 Input type nested option Output form rtable nested=false single-level (flattened) list rtable nested or nested=true nested list with structure reflecting input (*) array, matrix, vector nested=false single-level (flattened list) array, matrix, vector nested or nested=true nested list with structure reflecting input table with integer indices list ordered by table index other table unordered list string list of characters (equivalent to StringTools[Explode]) MultiSet [ op(Entries(expr)) ] other [ op(expr) ]

(*) If the rtable is 0-dimensional, the empty list is returned, rather than NULL.

 • Note that when converting an rtable to unnested list form, the order of elements in the output list will depend on the storage order of the rtable.

Examples

 > $\mathrm{convert}\left("abc",\mathrm{list}\right)$
 $\left[{"a"}{,}{"b"}{,}{"c"}\right]$ (1)
 > $A≔\mathrm{Array}\left(3..4,-1..1,0..3,\left(i,j,k\right)↦\frac{j+k}{i}\right):$
 > $\mathrm{convert}\left(A,\mathrm{list}\right)$
 $\left[{-}\frac{{1}}{{3}}{,}{-}\frac{{1}}{{4}}{,}{0}{,}{0}{,}\frac{{1}}{{3}}{,}\frac{{1}}{{4}}{,}{0}{,}{0}{,}\frac{{1}}{{3}}{,}\frac{{1}}{{4}}{,}\frac{{2}}{{3}}{,}\frac{{1}}{{2}}{,}\frac{{1}}{{3}}{,}\frac{{1}}{{4}}{,}\frac{{2}}{{3}}{,}\frac{{1}}{{2}}{,}{1}{,}\frac{{3}}{{4}}{,}\frac{{2}}{{3}}{,}\frac{{1}}{{2}}{,}{1}{,}\frac{{3}}{{4}}{,}\frac{{4}}{{3}}{,}{1}\right]$ (2)
 > $\mathrm{convert}\left(A,\mathrm{list},\mathrm{nested}\right)$
 $\left[\left[\left[{-}\frac{{1}}{{3}}{,}{0}{,}\frac{{1}}{{3}}{,}\frac{{2}}{{3}}\right]{,}\left[{0}{,}\frac{{1}}{{3}}{,}\frac{{2}}{{3}}{,}{1}\right]{,}\left[\frac{{1}}{{3}}{,}\frac{{2}}{{3}}{,}{1}{,}\frac{{4}}{{3}}\right]\right]{,}\left[\left[{-}\frac{{1}}{{4}}{,}{0}{,}\frac{{1}}{{4}}{,}\frac{{1}}{{2}}\right]{,}\left[{0}{,}\frac{{1}}{{4}}{,}\frac{{1}}{{2}}{,}\frac{{3}}{{4}}\right]{,}\left[\frac{{1}}{{4}}{,}\frac{{1}}{{2}}{,}\frac{{3}}{{4}}{,}{1}\right]\right]\right]$ (3)
 > $\mathrm{convert}\left(\mathrm{Array}\left(\right),\mathrm{list}\right)$
 $\left[\right]$ (4)
 > $\mathrm{convert}\left(⟨⟨1|2⟩,⟨3|4⟩⟩,\mathrm{list}\right)$
 $\left[{1}{,}{3}{,}{2}{,}{4}\right]$ (5)
 > $\mathrm{convert}\left(\mathrm{Matrix}\left(⟨⟨1|2⟩,⟨3|4⟩⟩,\mathrm{order}=\mathrm{C_order}\right),\mathrm{list}\right)$
 $\left[{1}{,}{2}{,}{3}{,}{4}\right]$ (6)
 > $\mathrm{convert}\left(f\left(a,b,c\right),\mathrm{list}\right)$
 $\left[{a}{,}{b}{,}{c}\right]$ (7)

The default behavior is to extract operands:

 > $\mathrm{~}\left[\mathrm{convert}\right]\left(\left[{x}^{2},{x}^{2}+2x,{x}^{2}+2x+1\right],\mathrm{list}\right)$
 $\left[\left[{x}{,}{2}\right]{,}\left[{{x}}^{{2}}{,}{2}{}{x}\right]{,}\left[{{x}}^{{2}}{,}{2}{}{x}{,}{1}\right]\right]$ (8)

By setting + as the expected_type, one can extract terms instead:

 > $\mathrm{~}\left[\mathrm{convert}\right]\left(\left[{x}^{2},{x}^{2}+2x,{x}^{2}+2x+1\right],\mathrm{list},\mathrm{+}\right)$
 $\left[\left[{{x}}^{{2}}\right]{,}\left[{{x}}^{{2}}{,}{2}{}{x}\right]{,}\left[{{x}}^{{2}}{,}{2}{}{x}{,}{1}\right]\right]$ (9)

Now get the factors in each term:

 > $\mathrm{~}\left[\mathrm{convert}\right]\left(\left[{x}^{2},2x,1\right],\mathrm{list},\mathrm{*}\right)$
 $\left[\left[{{x}}^{{2}}\right]{,}\left[{2}{,}{x}\right]{,}\left[{1}\right]\right]$ (10)

And the bases and exponents:

 > $\mathrm{~}\left[\mathrm{convert}\right]\left(\left[{x}^{2},x,1\right],\mathrm{list},\mathrm{^}\right)$
 $\left[\left[{x}{,}{2}\right]{,}\left[{x}{,}{1}\right]{,}\left[{1}{,}{1}\right]\right]$ (11)

Compatibility

 • The expected_type parameter was introduced in Maple 18.
 • For more information on Maple 18 changes, see Updates in Maple 18.

 See Also