[Oberon] How to mimic an associative array

Les May zen53397 at zen.co.uk
Sun Dec 5 15:15:25 CET 2010


On 04/12/2010 23:21, Douglas G. Danforth wrote:
> Folks,
>
> Does one want an associative 'array' or just an association?
> If one can associate two things x:y and retrieve one of them
> given the other then the implementation doesn't matter as
> long as it is efficient.
>
> -Doug
>
>
>
>    
This gets to the heart of the matter.

In a 'true' associative array I would expect to be able to associate 
"John" with "Smith" in something called NameTable, be able to write a 
line like:

LastName := NameTable["John"][ ]

and find that LastName held "Smith"

How this was implemented by the language designer would be no concern of 
mine.

The original query was about how to MIMIC this behaviour within the 
restrictions imposed by Oberon. Duke's original posting seems a 
perfectly valid way of forming a data structure which would associate 
pairs 'lastname' and 'firstname',  and which would permit the firstname 
to be retrieved if the lastname were known.

If the number of associated pairs was small even efficiency would not 
matter.

Les May






More information about the Oberon mailing list