2 indices - indices for specified matrix or association element
8 V matrix or association
11 return list with up to 4 elements
14 For 0 <= index < size(V), indices(V, index) returns list(i_0, i_1, ...)
15 for which V[i_0, i_1, ...] is the same lvalue as V[[index]].
17 For other values of index, a null value is returned.
19 This function can be useful for determining those elements for which
20 the indices satisfy some condition. This is particularly so for
21 associations since these have no simple relation between the
22 double-bracket index and the single-bracket indices, which may be
23 non-integer numbers or strings or other types of value. The
24 information provided by indices() is often required after the use
25 of search() or rsearch() which, when successful, return the
26 double-bracket index of the item found.
32 list (3 elements, 2 nonzero):
39 ; A["cat", "dog"] = "fight";
40 ; A[2,3,5,7] = "primes";
43 ; indices(A, search(A, "primes"))
44 list (4 elements, 4 nonzero):
54 LIST* associndices(ASSOC *ap, long index)
55 LIST* matindices(MATRIX *mp, long index)
60 ## Copyright (C) 1999-2006 Landon Curt Noll
62 ## Calc is open software; you can redistribute it and/or modify it under
63 ## the terms of the version 2.1 of the GNU Lesser General Public License
64 ## as published by the Free Software Foundation.
66 ## Calc is distributed in the hope that it will be useful, but WITHOUT
67 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
68 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
69 ## Public License for more details.
71 ## A copy of version 2.1 of the GNU Lesser General Public License is
72 ## distributed with calc under the filename COPYING-LGPL. You should have
73 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
74 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
76 ## @(#) $Revision: 30.1 $
77 ## @(#) $Id: indices,v 30.1 2007/03/16 11:10:42 chongo Exp $
78 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/indices,v $
80 ## Under source code control: 1999/11/16 08:02:03
81 ## File existed as early as: 1999
83 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
84 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/