bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] How awk keys are ordered?


From: Manuel Collado
Subject: Re: [bug-gawk] How awk keys are ordered?
Date: Wed, 21 Dec 2016 15:29:13 +0100
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/17.0 Thunderbird/17.0

El 21/12/2016 5:48, address@hidden escribió:
Quite right. Gawk has additional optimizations for arrays
indexed only by integers.  Running the program with another
awk will definitely give different results.

Of course. See below.


On Tue, Dec 20, 2016 at 3:13 PM, Peng Yu <address@hidden> wrote:

BEGIN {
     for(i=1;i<=26;i++) {
         array[i]=1
     }
     for(i in array) {
         print i
     }
     for(i=1;i<=26;i++) {
         array["" i] =1
     }
     for(i in array) {
         print i
     }
}

----------> GNU awk:

I:\pruebas\awk>gawk -f arrayorder.awk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

----------> Mike Brennan' awk

I:\pruebas\awk>mawk -f arrayorder.awk
3
10
8
6
15
5
23
2
11
26
1
16
25
4
22
12
21
18
17
24
9
7
14
13
20
19
3
10
8
6
15
5
23
2
11
26
1
16
25
4
22
12
21
18
17
24
9
7
14
13
20
19

----------> "new" awk

I:\pruebas\awk>nawk -f arrayorder.awk
22
2
23
3
24
4
25
5
26
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
1
22
2
23
3
24
4
25
5
26
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
1

----------> The one true awk

I:\pruebas\awk>awk95 -f arrayorder.awk
22
2
23
3
24
4
25
5
26
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
1
22
2
23
3
24
4
25
5
26
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
1

And please note that the awk spec says that array indexes are handled as strings. So [i] and ["" i] refer to the same element.

Regards.
--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado




reply via email to

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