 membertype - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Programming : Operations : Sets and lists : membertype

membertype

test a data structure, function, or module for a given type

 Calling Sequence membertype(x, s, 'p')

Parameters

 x - type s - set, list, table, function, or module 'p' - (optional) an unevaluated name

Description

 • The membertype(x, s) function determines if there is an operand within the expression s of type x.  Given a module, it determines if there is an assigned export of type x. If so, it returns true, and false otherwise.
 • If a third argument 'p' is present and membertype yields true, then the position of the first x in s is assigned to p in the case of sets and lists, whereas the member instance is assigned to the name p if s is a module.

Examples

Check whether either of the following sets contains an integer.

 > $\mathrm{membertype}\left(\mathrm{integer},\left\{7,3.2,\frac{1}{2}\right\}\right)$
 ${\mathrm{true}}$ (1)
 > $\mathrm{membertype}\left(\mathrm{integer},\left\{3.2,\frac{1}{2}\right\}\right)$
 ${\mathrm{false}}$ (2)

Check whether any of the three elements of this list is a product.

 > $\mathrm{membertype}\left(\mathrm{*},\left[xy,w+u,y\right],k\right)$
 ${\mathrm{true}}$ (3)
 > $k$
 ${1}$ (4)

Check whether this unevaluated function call has a symbol among its operands.

 > $\mathrm{membertype}\left(\mathrm{symbol},f\left(1,"a",x\right),'k'\right)$
 ${\mathrm{true}}$ (5)
 > $k$
 ${3}$ (6)

Search the exports of this module for one assigned to an integer.

 > $m≔\mathbf{module}\left(\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{_export}\left(e,f,g\right);\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}e≔4\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end module}:$
 > $\mathrm{membertype}\left(\mathrm{integer},m,'p'\right)$
 ${\mathrm{true}}$ (7)
 > $\mathrm{eval}\left(p,1\right),p$
 ${e}{,}{4}$ (8)

 See Also