number of indexable elements - Maple Help

numelems  - number of indexable elements

 Calling Sequence numelems(expr)

Parameters

 expr - expression

Description

 • The numelems(expr) command returns the number of elements in expr.
 • This command works on all expressions of type indexable.
 • If expr is an array, matrix or vector, the number of elements as represented by the bounds of the array is returned.  A 2x3 matrix will have 6 elements as reported by numelems, even if some of those elements are not assigned.  The same result will be returned if the matrix is sparse, or has another special storage as compared to a dense rectangular matrix.
 • If expr is a string, the number of characters in expr is returned.
 • If expr is a table, the number of assigned entries is returned.
 • If expr is a list or set, the number of first-level indexable elements is returned.  That is, a list containing two 5-element sublists will still have two elements as reported by numelems.  This is the same result given by nops.

Examples

 > $\mathrm{numelems}\left(⟨⟨1|2⟩,⟨3|4⟩⟩\right)$
 ${4}$ (1)
 > $\mathrm{numelems}\left(\left[1,2,3,4\right]\right)$
 ${4}$ (2)
 > $\mathrm{numelems}\left(\left[\left[1,2\right],\left[3,4\right]\right]\right)$
 ${2}$ (3)
 > $\mathrm{numelems}\left(\mathrm{table}\left(\left\{1=1,2=2,3=3\right\}\right)\right)$
 ${3}$ (4)
 > $\mathrm{numelems}\left("abc"\right)$
 ${3}$ (5)