type/array - Maple Programming Help

Home : Support : Online Help : Programming : Data Types : Type Checking : Types : type/array

type/array

check for an array

 Calling Sequence type(A, array) type(A, 'array'(t)) type(A, 'array'(n)) type(A, 'array'(x_1, x_2, ...))

Parameters

 A - any expression x_i - (optional) integer, range, type, or name

Description

 • The call type(A, array) checks to see if A is an array.  It will return true if A is an array, and false otherwise.  It does not check the entries of A. See the information under array for a description of the array data structure and how to create arrays.
 • The optional argument(s) must be either integers, ranges, names or a type.  They are used to specify the kind of array and the type of the entries of the array.
 • If x_i is an integer it specifies the number of dimensions of the array A.  For example, 'array'(2) would specify a 2-D array.
 • If ${x}_{1},{x}_{2},...,{x}_{n}$ are ranges, they specify the array bounds (and implicitly the dimension) of the array A.  For example, 'array'(1..2,1..posint) would specify a 2-D array with exactly two rows and one or more columns.
 • If ${x}_{1},...,{x}_{n}$ are names of indexing functions, they specify the kind of array.  For example, 'array'(symmetric) specifies a symmetric array, that is, an array with the symmetric indexing function.
 • If x is a type, it specifies the type of the entries of the array. For example, 'array'(numeric) specifies an array with numerical entries. See the information under type for a description of available types in Maple.  Note, if any entries of A are undefined, then their type will not be checked.  Thus if A is an array which has no defined elements, then type(A, 'array'(x)) will always return true.
 • It is necessary to surround the word array with quotes (') when using this function in the second form.  This prevents invocation of the array function, which is used to create arrays.
 • Note: The array command has been superseded by Array.

Examples

 > $A≔\mathrm{array}\left(1..2,1..2,\left[\left[1,3\right],\left[\frac{1}{2},5\right]\right]\right)$
 ${A}{≔}\left[\begin{array}{cc}{1}& {3}\\ \frac{{1}}{{2}}& {5}\end{array}\right]$ (1)
 > $\mathrm{type}\left(A,'\mathrm{array}'\left(\mathrm{rational}\right)\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{type}\left(A,'\mathrm{array}'\left(\mathrm{integer}\right)\right)$
 ${\mathrm{false}}$ (3)
 > $\mathrm{type}\left(A,'\mathrm{array}'\left(2\right)\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{type}\left(A,'\mathrm{array}'\left(1..2,1..2\right)\right)$
 ${\mathrm{true}}$ (5)
 > $\mathrm{type}\left(A,'\mathrm{array}'\left(1..2\right)\right)$
 ${\mathrm{false}}$ (6)
 > $B≔\mathrm{array}\left(1..3,\left[{x}^{2}+5,{x}^{3}-x,x+1\right]\right)$
 ${B}{≔}\left[\begin{array}{ccc}{{x}}^{{2}}{+}{5}& {{x}}^{{3}}{-}{x}& {x}{+}{1}\end{array}\right]$ (7)
 > $\mathrm{type}\left(B,'\mathrm{array}'\left(\mathrm{polynom}\right)\right)$
 ${\mathrm{true}}$ (8)
 > $\mathrm{type}\left(B,'\mathrm{array}'\left('\mathrm{polynom}'\left(\mathrm{integer},x\right)\right)\right)$
 ${\mathrm{true}}$ (9)
 > $C≔\mathrm{array}\left(0..2,2..4,\mathrm{symmetric}\right)$
 ${C}{≔}{array}{}\left({\mathrm{symmetric}}{,}{0}{..}{2}{,}{2}{..}{4}{,}\left[\left({0}{,}{2}\right){=}{{\mathrm{?}}}_{{0}{,}{2}}{,}\left({0}{,}{3}\right){=}{{\mathrm{?}}}_{{0}{,}{3}}{,}\left({0}{,}{4}\right){=}{{\mathrm{?}}}_{{0}{,}{4}}{,}\left({1}{,}{2}\right){=}{{\mathrm{?}}}_{{1}{,}{2}}{,}\left({1}{,}{3}\right){=}{{\mathrm{?}}}_{{1}{,}{3}}{,}\left({1}{,}{4}\right){=}{{\mathrm{?}}}_{{1}{,}{4}}{,}\left({2}{,}{2}\right){=}{{\mathrm{?}}}_{{2}{,}{2}}{,}\left({2}{,}{3}\right){=}{{\mathrm{?}}}_{{2}{,}{3}}{,}\left({2}{,}{4}\right){=}{{\mathrm{?}}}_{{2}{,}{4}}\right]\right)$ (10)
 > $\mathrm{type}\left(C,'\mathrm{array}'\left(2,\mathrm{symmetric}\right)\right)$
 ${\mathrm{true}}$ (11)
 > $\mathrm{type}\left(C,'\mathrm{array}'\left(1..2,1..2\right)\right)$
 ${\mathrm{false}}$ (12)
 > $\mathrm{type}\left(C,'\mathrm{array}'\left(0..\mathrm{posint},\mathrm{integer}..\mathrm{integer},\mathrm{symmetric}\right)\right)$
 ${\mathrm{true}}$ (13)