hasindex - Maple Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : hasindex

hasindex

test for whether object is indexed by a given object

 Calling Sequence hasindex(A, ind)

Parameters

 A - indexable or module; expression to check ind - (optional) expression sequence comprising index to be tested

Description

 • The function hasindex determines if ind is a valid index for the structure A; that is, whether A contains a value corresponding to the key ind.
 • If A is a table, hasindex tests whether ind is a key in the table.
 • If A is a module or record, hasindex tests whether ind is an export of the module.
 • If A is an rtable, hasindex tests whether ind is consistent with the dimensions of A. Note that ind may have fewer dimensions than A.
 • If A is an list, set, or string, hasindex tests whether ind is a nonzero integer whose absolute value does not exceed the length of A.

Examples

 > $L≔\left["quick","brown","fox"\right]$
 ${L}{≔}\left[{"quick"}{,}{"brown"}{,}{"fox"}\right]$ (1)
 > $\mathrm{hasindex}\left(L,2\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{hasindex}\left(L,4\right)$
 ${\mathrm{false}}$ (3)
 > $M≔\mathrm{LinearAlgebra}:-\mathrm{VandermondeMatrix}\left(⟨1,2,3,5⟩\right)$
 ${M}{≔}\left[\begin{array}{cccc}{1}& {1}& {1}& {1}\\ {1}& {2}& {4}& {8}\\ {1}& {3}& {9}& {27}\\ {1}& {5}& {25}& {125}\end{array}\right]$ (4)
 > $\mathrm{hasindex}\left(M,2,3\right)$
 ${\mathrm{true}}$ (5)
 > $\mathrm{hasindex}\left(M,3,5\right)$
 ${\mathrm{false}}$ (6)
 > $m≔\mathbf{module}\left(\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{_export}\left(e\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end module}:$
 > $\mathrm{hasindex}\left(m,e\right)$
 ${\mathrm{true}}$ (7)
 > $\mathrm{hasindex}\left(m,f\right)$
 ${\mathrm{false}}$ (8)
 > $\mathrm{ds}≔\mathrm{DataSeries}\left(\left[32,25,42\right],\mathrm{labels}=\left[X,Y,Z\right]\right)$
 ${\mathrm{ds}}{≔}\left[\begin{array}{cc}{X}& {32}\\ {Y}& {25}\\ {Z}& {42}\end{array}\right]$ (9)
 > $\mathrm{hasindex}\left(\mathrm{ds},X\right)$
 ${\mathrm{true}}$ (10)

Compatibility

 • The hasindex command was introduced in Maple 2020.
 • For more information on Maple 2020 changes, see Updates in Maple 2020.

 See Also