bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: delete of nested array is in consistent


From: Peng Yu
Subject: Re: delete of nested array is in consistent
Date: Thu, 16 Apr 2020 18:21:30 -0500

So then if I want to use a multidimensional array with multiple split
statements, how should I initalize the multidimensional array?

split(s1, a[1], r1)
split(s2, a[2], r2)
....

On 4/16/20, david kerns <address@hidden> wrote:
> pretty sure gawk still doesn't have "true" multi-dimensional arrays...
>
> A *multidimensional array* is an array in which an element is identified by
> a sequence of indices instead of a single index. For example, a
> two-dimensional array requires two indices. The usual way (in many
> languages, including awk) to refer to an element of a two-dimensional array
> named grid is with grid[x,y].
>
> Multidimensional arrays are supported in awk through concatenation of
> indices into one string. awk converts the indices into strings (see
> section Conversion
> of Strings and Numbers
> <https://www.gnu.org/software/gawk/manual/html_node/Conversion.html#Conversion>)
> and concatenates them together, with a separator between them. This creates
> a single string that describes the values of the separate indices. The
> combined string is used as a single index into an ordinary, one-dimensional
> array. The separator used is the value of the built-in variable SUBSEP.
>
> On Thu, Apr 16, 2020 at 3:31 PM Peng Yu <address@hidden> wrote:
>
>> See below. I'd expect the second one should also print array. Is it a
>> bug?
>>
>> $ awk -e 'BEGIN { delete a[""]; print typeof(a) }'
>> array
>> $ awk -e 'BEGIN { delete a[1][""]; print typeof(a[1]) }'
>> unassigned
>>
>> --
>> Regards,
>> Peng
>>
>>
>


-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]