modified: diffout.py
[GalaxyCodeBases.git] / c_cpp / etc / calc / help / indices
blob3ec8250d209a87900d33787ad49ca4b230bb47df
1 NAME
2     indices - indices for specified matrix or association element
4 SYNOPSIS
5     indices(V, index)
7 TYPES
8     V           matrix or association
9     index       integer
11     return      list with up to 4 elements
13 DESCRIPTION
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.
28 EXAMPLE
29     ; mat M[2,3,1:5]
31     ; indices(M, 11)
32     list (3 elements, 2 nonzero):
33             [[0]] = 0
34             [[1]] = 2
35             [[2]] = 2
37     ; A = assoc();
39     ; A["cat", "dog"] = "fight";
40     ; A[2,3,5,7] = "primes";
41     ; A["square", 3] = 9
43     ; indices(A, search(A, "primes"))
44     list (4 elements, 4 nonzero):
45             [[0]] = 2
46             [[1]] = 3
47             [[2]] = 5
48             [[3]] = 7
50 LIMITS
51     abs(index) < 2^31
53 LINK LIBRARY
54     LIST* associndices(ASSOC *ap, long index)
55     LIST* matindices(MATRIX *mp, long index)
57 SEE ALSO
58     assoc, mat
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/