set - Maple Help

convert/set

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

Parameters

 expr - expression to convert expected_type - (optional) + or * nested_op - (optional) equation 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 set 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 or factors 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 or a product of one factor. The return value is {expr} in the trivial case.
 • 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) set rtable nested or nested=true nested set with structure reflecting input (*) array, matrix, vector nested=false single-level (flattened set) array, matrix, vector nested or nested=true nested set with structure reflecting input table unordered set string set of characters (equivalent to StringTools[Explode] converted to set) MultiSet Members(expr) other { op(expr) }

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

Examples

 > $\mathrm{convert}\left("abc",\mathrm{set}\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{set}\right)$
 $\left\{{0}{,}{1}{,}{-}\frac{{1}}{{3}}{,}{-}\frac{{1}}{{4}}{,}\frac{{1}}{{2}}{,}\frac{{1}}{{3}}{,}\frac{{1}}{{4}}{,}\frac{{2}}{{3}}{,}\frac{{3}}{{4}}{,}\frac{{4}}{{3}}\right\}$ (2)
 > $\mathrm{convert}\left(A,\mathrm{set},\mathrm{nested}\right)$
 $\left\{\left\{\left\{{0}{,}{1}{,}\frac{{1}}{{3}}{,}\frac{{2}}{{3}}\right\}{,}\left\{{0}{,}{-}\frac{{1}}{{3}}{,}\frac{{1}}{{3}}{,}\frac{{2}}{{3}}\right\}{,}\left\{{1}{,}\frac{{1}}{{3}}{,}\frac{{2}}{{3}}{,}\frac{{4}}{{3}}\right\}\right\}{,}\left\{\left\{{0}{,}{-}\frac{{1}}{{4}}{,}\frac{{1}}{{2}}{,}\frac{{1}}{{4}}\right\}{,}\left\{{0}{,}\frac{{1}}{{2}}{,}\frac{{1}}{{4}}{,}\frac{{3}}{{4}}\right\}{,}\left\{{1}{,}\frac{{1}}{{2}}{,}\frac{{1}}{{4}}{,}\frac{{3}}{{4}}\right\}\right\}\right\}$ (3)
 > $\mathrm{convert}\left(\mathrm{Array}\left(\right),\mathrm{set}\right)$
 ${\varnothing }$ (4)
 > $\mathrm{convert}\left(⟨⟨1|2⟩,⟨3|4⟩⟩,\mathrm{set}\right)$
 $\left\{{1}{,}{2}{,}{3}{,}{4}\right\}$ (5)
 > $\mathrm{convert}\left(f\left(a,b,c\right),\mathrm{set}\right)$
 $\left\{{a}{,}{b}{,}{c}\right\}$ (6)

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{set}\right)$
 $\left[\left\{{2}{,}{x}\right\}{,}\left\{{{x}}^{{2}}{,}{2}{}{x}\right\}{,}\left\{{1}{,}{{x}}^{{2}}{,}{2}{}{x}\right\}\right]$ (7)

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{set},\mathrm{+}\right)$
 $\left[\left\{{{x}}^{{2}}\right\}{,}\left\{{{x}}^{{2}}{,}{2}{}{x}\right\}{,}\left\{{1}{,}{{x}}^{{2}}{,}{2}{}{x}\right\}\right]$ (8)

Now get the factors in each term:

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

Compatibility

 • The nested_op parameter was introduced in Maple 16.