 indices - Maple Programming Help

indices

indices of a table or array

entries

entries of a table or array

 Calling Sequence indices(t) indices(t,options) entries(t) entries(t,options)

Parameters

 t - table or Array options - (optional) optional arguments to control the output format.

Description

 • The indices and entries functions return sequences of the indices (or keys) and the entries respectively of the table or Array t corresponding to the entries that are explicitly stored.
 • By default, the result returned is a sequence of lists in an apparently arbitrary order. However, there is a one-to-one correspondence between the result of indices and entries.  Users can specify the 'indexorder' option to control the order of the returned elements.
 • indices and entries support the following optional arguments.
 • If the 'nolist' option is used the result returned will be a simple sequence without lists.  This is useful for tables where every index or entry is a single object.  When 'nolist' is used on a table with expression sequence indices or entries, the pairings may be difficult to deduce in the result.
 • If the 'pairs' option is used the result returned will be a sequence of index = entry pairs.  Since the equation form can represent sequences in either the index or entry part of the equation, neither each side nor the whole equation is wrapped in a list.
 • If the 'indexorder' option is used the returned data will be ordered based on the sorted order of the indices.  The indices are sorted using the same algorithm as the sort command.  Users can also provide a comparison function to the 'indexorder' option.

 • The indices and entries commands are thread-safe as of Maple 15.

Examples

 > $t≔\mathrm{table}\left(\left[\mathrm{green}=\mathrm{gruen},\mathrm{red}=\mathrm{rot},\mathrm{blue}=\mathrm{blau},\mathrm{black}=\mathrm{schwarz}\right]\right):$
 > $\mathrm{indices}\left(t\right)$
 $\left[{\mathrm{red}}\right]{,}\left[{\mathrm{green}}\right]{,}\left[{\mathrm{black}}\right]{,}\left[{\mathrm{blue}}\right]$ (1)
 > $\mathrm{entries}\left(t\right)$
 $\left[{\mathrm{rot}}\right]{,}\left[{\mathrm{gruen}}\right]{,}\left[{\mathrm{schwarz}}\right]{,}\left[{\mathrm{blau}}\right]$ (2)
 > $\mathrm{indices}\left(t,'\mathrm{nolist}'\right)$
 ${\mathrm{red}}{,}{\mathrm{green}}{,}{\mathrm{black}}{,}{\mathrm{blue}}$ (3)
 > $\mathrm{indices}\left(t,'\mathrm{pairs}'\right)$
 ${\mathrm{red}}{=}{\mathrm{rot}}{,}{\mathrm{green}}{=}{\mathrm{gruen}}{,}{\mathrm{black}}{=}{\mathrm{schwarz}}{,}{\mathrm{blue}}{=}{\mathrm{blau}}$ (4)
 > $\mathrm{indices}\left(t,\mathrm{indexorder}\right)$
 $\left[{\mathrm{black}}\right]{,}\left[{\mathrm{blue}}\right]{,}\left[{\mathrm{green}}\right]{,}\left[{\mathrm{red}}\right]$ (5)
 > $\mathrm{entries}\left(t,\mathrm{indexorder}\right)$
 $\left[{\mathrm{schwarz}}\right]{,}\left[{\mathrm{blau}}\right]{,}\left[{\mathrm{gruen}}\right]{,}\left[{\mathrm{rot}}\right]$ (6)
 > $\mathrm{indices}\left(t,\mathrm{indexorder}=\left(\left(x,y\right)→\mathbf{not}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{StringTools}:-\mathrm{Compare}\left({x}_{1},{y}_{1}\right)\right)\right)$
 $\left[{\mathrm{red}}\right]{,}\left[{\mathrm{green}}\right]{,}\left[{\mathrm{blue}}\right]{,}\left[{\mathrm{black}}\right]$ (7)
 > $a≔\mathrm{Array}\left(\left[\left[1,2\right],\left[3,4\right]\right]\right)$
 ${a}{≔}\left[\begin{array}{cc}{1}& {2}\\ {3}& {4}\end{array}\right]$ (8)
 > $\mathrm{indices}\left(a\right)$
 $\left[{1}{,}{1}\right]{,}\left[{2}{,}{1}\right]{,}\left[{1}{,}{2}\right]{,}\left[{2}{,}{2}\right]$ (9)
 > $\mathrm{entries}\left(a\right)$
 $\left[{1}\right]{,}\left[{3}\right]{,}\left[{2}\right]{,}\left[{4}\right]$ (10)
 > $\mathrm{entries}\left(a,'\mathrm{nolist}'\right)$
 ${1}{,}{3}{,}{2}{,}{4}$ (11)
 > $m≔\mathrm{Matrix}\left(3,2,\left[\left[2,-1\right],\left[4,4\right],\left[5,8\right]\right]\right)$
 ${m}{≔}\left[\begin{array}{cc}{2}& {-1}\\ {4}& {4}\\ {5}& {8}\end{array}\right]$ (12)
 > $\mathrm{indices}\left(m\right)$
 $\left[{1}{,}{1}\right]{,}\left[{2}{,}{1}\right]{,}\left[{3}{,}{1}\right]{,}\left[{1}{,}{2}\right]{,}\left[{2}{,}{2}\right]{,}\left[{3}{,}{2}\right]$ (13)
 > $\mathrm{entries}\left(m\right)$
 $\left[{2}\right]{,}\left[{4}\right]{,}\left[{5}\right]{,}\left[{-1}\right]{,}\left[{4}\right]{,}\left[{8}\right]$ (14)
 > $\mathrm{entries}\left(m,'\mathrm{pairs}'\right)$
 $\left({1}{,}{1}\right){=}{2}{,}\left({1}{,}{2}\right){=}{-1}{,}\left({2}{,}{1}\right){=}{4}{,}\left({2}{,}{2}\right){=}{4}{,}\left({3}{,}{1}\right){=}{5}{,}\left({3}{,}{2}\right){=}{8}$ (15)

Compatibility

 • The pairs option was introduced in Maple 15.