In article <[EMAIL PROTECTED]>, you wrote:
>I think select and paths should come close to what you're asking:

>>> select [ a "this is a" b "this is b" ] 'a
>== "this is a"

I'll have to ponder that for a while but my first thought
is that doing it that way would make it difficult to
populate it from a data file of arbitrary data.

Here is a snipit from the Awk doc's that explains what I'm
after.

--------------------------------------------------------
http://www.gnu.org/manual/gawk-3.0.3/html_chapter/gawk_12.html

Arrays in awk superficially resemble arrays in other
programming languages; but there are fundamental
differences. In awk, you don't need to specify the size of
an array before you start to use it. Additionally, any
number or string in awk may be used as an array index, not
just consecutive integers.

In most other languages, you have to declare an array and
specify how many elements or components it contains. In such
languages, the declaration causes a contiguous block of
memory to be allocated for that many elements. An index in
the array usually must be a positive integer; for example,
the index zero specifies the first element in the array,
which is actually stored at the beginning of the block of
memory. Index one specifies the second element, which is
stored in memory right after the first element, and so on.
It is impossible to add more elements to the array, because
it has room for only as many elements as you declared. (Some
languages allow arbitrary starting and ending indices, e.g.,
`15 .. 27', but the size of the array is still fixed when
the array is declared.)

A contiguous array of four elements might look like this,
conceptually, if the element values are eight, "foo", "" and
30:

Only the values are stored; the indices are implicit from
the order of the values. Eight is the value at index zero,
because eight appears in the position with zero elements
before it.

Arrays in awk are different: they are associative. This
means that each array is a collection of pairs: an index,
and its corresponding array element value:

Element 4     Value 30
Element 2     Value "foo"
Element 1     Value 8
Element 3     Value ""

We have shown the pairs in jumbled order because their order
is irrelevant.

One advantage of associative arrays is that new pairs can be
added at any time. For example, suppose we add to the above
array a tenth element whose value is "number ten". The
result is this...

Reply via email to