| 1 |
# test the "in" keyword with maps |
| 2 |
|
| 3 |
global a, b, c |
| 4 |
|
| 5 |
probe begin { |
| 6 |
for (i=0;i<11;i++) |
| 7 |
a[i] = i*i |
| 8 |
|
| 9 |
if (0 in a) printf("0 is there\n") |
| 10 |
if (1 in a) printf("1 is there\n") |
| 11 |
if (50 in a) printf("ERROR: 50 is there\n") |
| 12 |
|
| 13 |
printf("complete list for a: ") |
| 14 |
for (i=0;i<11;i++) |
| 15 |
if (i in a) printf("%d ", i) |
| 16 |
printf("\n") |
| 17 |
|
| 18 |
a[0] = 0 |
| 19 |
if (0 in a) printf("0 is still there\n") |
| 20 |
|
| 21 |
delete a[0] |
| 22 |
if (0 in a) printf("ERROR: 0 is there after delete\n") |
| 23 |
|
| 24 |
for (i=0;i<11;i++) |
| 25 |
b[i, 10*i] = i*i |
| 26 |
printf("complete list for b: ") |
| 27 |
for (i=0;i<11;i++) |
| 28 |
if ([i,10*i] in b) printf("[%d,%d] ", i, 10*i) |
| 29 |
printf("\n") |
| 30 |
b[0,0] = 0 |
| 31 |
if ([0,0] in b) printf("[0,0] is still there\n") |
| 32 |
|
| 33 |
delete b[0,0] |
| 34 |
if ([0,0] in b) printf("ERROR: [0,0] is there after delete\n") |
| 35 |
|
| 36 |
c[""] = "empty string" |
| 37 |
c["hello"] = "HELLO" |
| 38 |
if ([""] in c) printf ("empty string there\n") |
| 39 |
if (["hello"] in c) printf ("hello there\n") |
| 40 |
c[""] = "" |
| 41 |
if ([""] in c) printf ("empty string still there\n") |
| 42 |
delete c[""] |
| 43 |
if ([""] in c) printf ("ERROR: empty string still there after delete\n") |
| 44 |
exit() |
| 45 |
} |
| 46 |
|