From: thdyoung on
am I right, Janis ?
From: Ed Morton on
On 8/6/2010 8:20 AM, thdyoung(a)googlemail.com wrote:
> On Aug 6, 12:59 am, Ed Morton<mortons...(a)gmail.com> wrote:
>> On Aug 5, 3:52 pm, "thdyo...(a)googlemail.com"<thdyo...(a)gmail.com>
>> wrote:

<please don't top-post, fixed below>

>>
>>> A lot to think about it.
>>
>> Try this:
>>
>> array = hotel
>> index = room number
>> memory where an element is stored = room
>> element = bed
>>
>> You can't have a hotel with 2 rooms with identical numbers, but you
>> can have identical beds in multiple rooms.
>>
>> Ed.
>
> But isn't Janis saying - "you can't have a different room number when
> the bed in it is identical to another one" ? That's why the array
> length stays the same for lines of input w the same first field.
>
> Tom
>

No, he's saying you can't have 2 rooms with the same room number. It's

arrayX[index1] == elementA
The value "elementA" is stored in "index1" position in array "arrayX"

hotelY[room number7] == bedX
The furniture "bedX" is stored in "room number7" room in hotel "hotelY"

I tried using "bed" for simplicity but it'd really be closer to reality think of
the element as a specific collection of all the furniture in the room, so you
could have:

arrayX[index1] == elementA
hotelY[room number7] == furnitureX

and "elementA" could be "3" or "3, f, bob" or any other number or string (or
more complex data structure in other languages), just like "furnitureX" could be
"bed" or "bed1, bed2, lamp, couch, t.v.", etc.

The point is that you can have:

arrayX[index1] == elementA (the number 3)
arrayX[index2] == elementA (the number 3)
hotelY[room number7] == furnitureX (2 queen beds plus tv)
hotelY[room number8] == furnitureX (2 queen beds plus tv)

but you can't have:

arrayX[index1] == elementA (the number 3)
arrayX[index1] == elementB (the string "foo")
hotelY[room number7] == furnitureX (2 queen beds plus tv)
hotelY[room number7] == furnitureY (1 king bed plus microwave)

i.e. it makes no more sense to say that the memory at "index1" of array "arrayX"
has both the value of number 3 and the string "foo" than it'd make to say "hotel
room number 7 has a 2 queen beds and a tv and nothing else" and then also say
"hotel room number 7 has 1 king bed and a microwave but no tv or anything else".

Hope that doesn't muddy the waters even more.

Regards,

Ed.
From: Ed Morton on
On 8/6/2010 8:34 AM, Janis Papanagnou wrote:
> On 06/08/10 15:20, thdyoung(a)googlemail.com wrote:
>> On Aug 6, 12:59 am, Ed Morton<mortons...(a)gmail.com> wrote:
>>> On Aug 5, 3:52 pm, "thdyo...(a)googlemail.com"<thdyo...(a)gmail.com>
>>> wrote:
>>>
>>>> Thank you Janis.
>> But isn't Janis saying - "you can't have a different room number when
>> the bed in it is identical to another one" ? That's why the array
>> length stays the same for lines of input w the same first field.
>
> (I was not talking about rooms. :-)

Sorry, I got hooked on using real-world analogies for OO patterns (e.g. "State"
== "the preset buttons on your radio", "Composite" == "company org structure",
etc.) back in the day and just can't seem to shake it. Works well if you get the
right analogy! If you don't though....

Ed.
>
> To address an associative awk array you have exactly one key, and
> you have exactly one place (per key) to store a value that is then
> associated with that key.
>
> Janis
>
>>
>> Tom
>>
>>>
>>>> A lot to think about it.
>>>
>>> Try this:
>>>
>>> array = hotel
>>> index = room number
>>> memory where an element is stored = room
>>> element = bed
>>>
>>> You can't have a hotel with 2 rooms with identical numbers, but you
>>> can have identical beds in multiple rooms.
>>>
>>> Ed.
>>
>

From: thdyoung on
I am reaching the point in the discussion when it's as well to stop. I
am not getting any more illumination and recognise the problem is
local not remote. But thanx Ed, Janis.

arrayX[index1] == elementA (the number 3)
arrayX[index2] == elementA (the number 3)

The above looks to me like the OK for an array to happily include
identical values w a different key.

But I don't want to bore you by carrying on. I will now revert to
lurk.

Tom
From: Ed Morton on
On 8/6/2010 9:17 AM, thdyoung(a)googlemail.com wrote:
> I am reaching the point in the discussion when it's as well to stop. I
> am not getting any more illumination and recognise the problem is
> local not remote. But thanx Ed, Janis.
>
> arrayX[index1] == elementA (the number 3)
> arrayX[index2] == elementA (the number 3)
>
> The above looks to me like the OK for an array to happily include
> identical values w a different key.

It IS OK, that's what I said. What I said is NOT OK is:

arrayX[index1] == elementA (the number 3)
arrayX[index1] == elementB (the string "foo")

Ed.

>
> But I don't want to bore you by carrying on. I will now revert to
> lurk.
>
> Tom