convert/list
Calling Sequence
Parameters
Description
Examples
Compatibility
convert( expr, list, expected_type )
convert( expr, list, nested_op )
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
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
nested or nested=true
nested list with structure reflecting input (*)
array, matrix, vector
single-level (flattened list)
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.
convert⁡abc,list
a,b,c
A≔Array⁡3..4,−1..1,0..3,i,j,k↦j+ki:
convert⁡A,list
−13,−14,0,0,13,14,0,0,13,14,23,12,13,14,23,12,1,34,23,12,1,34,43,1
convert⁡A,list,nested
−13,0,13,23,0,13,23,1,13,23,1,43,−14,0,14,12,0,14,12,34,14,12,34,1
convert⁡Array⁡,list
convert⁡1|2,3|4,list
1,3,2,4
convert⁡Matrix⁡1|2,3|4,order=C_order,list
1,2,3,4
convert⁡f⁡a,b,c,list
The default behavior is to extract operands:
`~`convert⁡x2,x2+2⁢x,x2+2⁢x+1,list
x,2,x2,2⁢x,x2,2⁢x,1
By setting `+` as the expected_type, one can extract terms instead:
`~`convert⁡x2,x2+2⁢x,x2+2⁢x+1,list,`+`
x2,x2,2⁢x,x2,2⁢x,1
Now get the factors in each term:
`~`convert⁡x2,2⁢x,1,list,`*`
x2,2,x,1
And the bases and exponents:
`~`convert⁡x2,x,1,list,`^`
x,2,x,1,1,1
The expected_type parameter was introduced in Maple 18.
For more information on Maple 18 changes, see Updates in Maple 18.
See Also
convert
convert/set
entries
StringTools[Explode]
Download Help Document
What kind of issue would you like to report? (Optional)