Task

Using two Arrays of equal length, create a Hash object
where the elements from one array (the keys) are linked
to the elements of the other (the values)



Related task

   Associative arrays/Creation


program HashFromTwoArrays (Output);
 
uses
  contnrs;
 
var
  keys:   array[1..3] of string  = ('a', 'b', 'c');
  values: array[1..3] of integer = ( 1,   2,   3 );
  hash:   TFPDataHashTable;
  i:      integer;
 
begin
  hash := TFPDataHashTable.Create;
  for i := low(keys) to high(keys) do
    hash.add(keys[i], @values[i]);
  writeln ('Length of hash table: ', hash.Count);
  hash.Destroy;
end.