Hash from two arrays: Difference between revisions

From Rosetta Code
Content added Content deleted
(revert spam)
mNo edit summary
Line 1: Line 1:
[http://pupsik1993.ifrance.com/love-philosophy.html love philosophy] [http://katzella.ifrance.com/himno-a-quito/index.html himno a quito] [http://katzella.ifrance.com/hitparade/index.html hitparade] [http://plyuh-vios.ifrance.com/its-not-easy.html its not easy] [http://cuivenarius.ifrance.com/hells-kitchen-original.html hells kitchen original soundtrack] [http://busjavka.ifrance.com/hotel-la-giada/index.html hotel la giada] [http://alexandraa80.ifrance.com/latte-per-neonati/index.html latte per neonati miltina] [http://alexandraa80.ifrance.com/la-decapitazione/index.html la decapitazione dell ostaggio] [http://plyuh-vios.ifrance.com/io-ho-te-audio2.html io ho te audio2] [http://xxxenichkaa.ifrance.com/lotto-di-milano.html lotto di milano] [http://xxxenichkaa.ifrance.com/leslie-amine.html leslie amine] [http://eliasn5gh.ifrance.com/liefdeskapitein.html liefdeskapitein] [http://pupsik1993.ifrance.com/lesli-et-amin.html lesli et amin] [http://busjavka.ifrance.com/heresy-mondavio/index.html heresy mondavio] [http://oddonpurpose.ifrance.com/la-donna-riccia.html la donna riccia modugno] [http://katzella.ifrance.com/hilary-dutf/index.html hilary dutf] [http://busjavka.ifrance.com/has-tabulas/index.html has tabulas verres abstulit] [http://xxxenichkaa.ifrance.com/lee-ryan-why-me.html lee ryan why me] [http://thecrownless.ifrance.com/inno-spagnolo-score/index.html inno spagnolo score] [http://child-ofadot.ifrance.com/irdeto-plugin-skystar.html irdeto plugin skystar 2] [http://snakeystil.ifrance.com/jamás/index.html jamás] [http://plyuh-vios.ifrance.com/il-magnate-greco.html il magnate greco] [http://fluffy-mind.ifrance.com/kemal-malovcic.html kemal malovcic midi] [http://oddonpurpose.ifrance.com/la-valle-dell-eden.html la valle dell eden] [http://xxxenichkaa.ifrance.com/la-panthere-rose.html la panthere rose] [http://oddonpurpose.ifrance.com/la-quindicesima.html la quindicesima epistola] [http://carbonphoenix.ifrance.com/juan-alfonso-baptista.html juan alfonso baptista] [http://chasingspaces.ifrance.com/hagen-nina/index.html hagen nina] [http://starcross33.ifrance.com/letr-de-hoobastank/index.html letr de hoobastank] [http://thecrownless.ifrance.com/i-consigli-un/index.html i consigli un pirla] [http://taylors-acolyte.ifrance.com/ighina-it.html ighina it] [http://fluffy-mind.ifrance.com/kisses-of-no-return.html kisses of no return] [http://child-ofadot.ifrance.com/isola-del-tesoro.html isola del tesoro] [http://listmishyk.ifrance.com/kobra/index.html kobra] [http://angeljazz711.ifrance.com/inviati-di-uno-mattina.html inviati di uno mattina] [http://starcross33.ifrance.com/lepoglava/index.html lepoglava] [http://busjavka.ifrance.com/hotel-altavilla-spello/index.html hotel altavilla spello] [http://taylors-acolyte.ifrance.com/immagini-del-giappone.html immagini del giappone] [http://risdimpuka.ifrance.com/leggi-industria/index.html leggi industria della carta] [http://eliasn5gh.ifrance.com/lovefool-the-cardigans.html lovefool the cardigans] [http://listmishyk.ifrance.com/katie-holmes-nuda/index.html katie holmes nuda] [http://starcross33.ifrance.com/la-bigate/index.html la bigate] [http://eliasn5gh.ifrance.com/luca-di-rio.html luca di rio] [http://xxxenichkaa.ifrance.com/la-2-gurra-mondiale.html la 2 gurra mondiale] [http://chasingspaces.ifrance.com/here-whitout-you/index.html here whitout you] [http://katzella.ifrance.com/here-with-me-dido/index.html here with me dido] [http://fluffy-mind.ifrance.com/kenya.html kenya] [http://alexandraa80.ifrance.com/lionel-richie/index.html lionel richie testo angel] [http://angeljazz711.ifrance.com/in-the-middle-sugababes.html in the middle sugababes] [http://katzella.ifrance.com/hea/index.html hea] [http://busjavka.ifrance.com/haïduci/index.html haïduci] [http://eliasn5gh.ifrance.com/luna-by-verdena.html luna by verdena] [http://plyuh-vios.ifrance.com/il-barone-brigate.html il barone brigate rossonere] [http://alexandraa80.ifrance.com/letteratura-trecentesca/index.html letteratura trecentesca] [http://oddonpurpose.ifrance.com/locandina-film-vanilla.html locandina film vanilla sky tom cruise] [http://chasingspaces.ifrance.com/greased-lightning/index.html greased lightning] [http://taylors-acolyte.ifrance.com/istanbul.html istanbul] [http://fluffy-mind.ifrance.com/kimsun.html kimsun] [http://child-ofadot.ifrance.com/il-tirreno-del.html il tirreno del 1 08 04] [http://oddonpurpose.ifrance.com/la-citta-e-pulcinella.html la citta e pulcinella] [http://katzella.ifrance.com/hp-635/index.html hp 635] [http://risdimpuka.ifrance.com/liquet/index.html liquet] [http://eliasn5gh.ifrance.com/lose-weight-by-jucing.html lose weight by jucing] [http://chasingspaces.ifrance.com/galimberti-nino/index.html galimberti nino] [http://carbonphoenix.ifrance.com/jesi.html jesi] [http://thecrownless.ifrance.com/invio-sms-gratuito/index.html invio sms gratuito] [http://starcross33.ifrance.com/love-come-again/index.html love come again] [http://xxxenichkaa.ifrance.com/laura-gemser.html laura gemser] [http://listmishyk.ifrance.com/kurt-waill/index.html kurt waill] [http://taylors-acolyte.ifrance.com/inno-al-trentino.html inno al trentino] [http://listmishyk.ifrance.com/kilye-minogue/index.html kilye minogue] [http://alexandraa80.ifrance.com/laura-pasuini/index.html laura pasuini] [http://risdimpuka.ifrance.com/la-vittoria-di/index.html la vittoria di] [http://fluffy-mind.ifrance.com/kuca-hrvatska-korcula.html kuca hrvatska korcula] [http://snakeystil.ifrance.com/jose-antonio-bordell/index.html jose antonio bordell kassandra] [http://alexandraa80.ifrance.com/la-nina-la-pinta-e/index.html la nina la pinta e la santa maria] [http://carbonphoenix.ifrance.com/ja-sei-na-morar.html ja sei na morar tribalistas] [http://cuivenarius.ifrance.com/homevideo.html homevideo] [http://thecrownless.ifrance.com/industrie-mobili/index.html industrie mobili] [http://risdimpuka.ifrance.com/los-panchos/index.html los panchos] [http://angeljazz711.ifrance.com/il-potere.html il potere] [http://thecrownless.ifrance.com/insieme-mina/index.html insieme mina] [http://xxxenichkaa.ifrance.com/legge-449.html legge 449] [http://taylors-acolyte.ifrance.com/immagini-xxx.html immagini xxx] [http://fluffy-mind.ifrance.com/k9.html k9] [http://thecrownless.ifrance.com/indirizzi-a-parma/index.html indirizzi a parma] [http://starcross33.ifrance.com/lloyd-ft-ashanti/index.html lloyd ft ashanti] [http://fluffy-mind.ifrance.com/konkretna-piosenka.html konkretna piosenka] [http://chasingspaces.ifrance.com/hotels-taormina/index.html hotels taormina] [http://eliasn5gh.ifrance.com/lee-rayan-fotos.html lee rayan fotos xx] [http://oddonpurpose.ifrance.com/la-mer.html la mer] [http://fluffy-mind.ifrance.com/kinsky.html kinsky] [http://risdimpuka.ifrance.com/lotr/index.html lotr] [http://oddonpurpose.ifrance.com/la-nascita-del-lavoro.html la nascita del lavoro] [http://cuivenarius.ifrance.com/hej-ljubavi-u-dalekom.html hej ljubavi u dalekom gradu] [http://risdimpuka.ifrance.com/lambada-mmf/index.html lambada mmf] [http://taylors-acolyte.ifrance.com/italo-music.html italo music] [http://oddonpurpose.ifrance.com/lotto-corriere.html lotto corriere] [http://fluffy-mind.ifrance.com/kristaallen.html kristaallen] [http://plyuh-vios.ifrance.com/internet-italiana.html internet italiana] [http://fluffy-mind.ifrance.com/kir2kos.html kir2kos] [http://listmishyk.ifrance.com/kaspar-kapparoni/index.html kaspar kapparoni] [http://child-ofadot.ifrance.com/istituto-nazionale.html istituto nazionale urbanistica] [http://taylors-acolyte.ifrance.com/ibarra.html ibarra] [http://listmishyk.ifrance.com/k448-mozart/index.html k448 mozart] [http://pupsik1993.ifrance.com/luigi-xv.html luigi xv] [http://busjavka.ifrance.com/ho-capito-che-ti/index.html ho capito che ti amo luigi tenco] [http://angeljazz711.ifrance.com/il-gladiatore.html il gladiatore free midi] [http://risdimpuka.ifrance.com/laura-corradin/index.html laura corradin] [http://listmishyk.ifrance.com/karaoke-vecchioni/index.html karaoke vecchioni] [http://xxxenichkaa.ifrance.com/lingua-francese.html lingua francese pisa] [http://fluffy-mind.ifrance.com/kily.html kily] [http://carbonphoenix.ifrance.com/jordan-peele.html jordan peele] [http://snakeystil.ifrance.com/jay-z-i-beyonce/index.html jay z i beyonce] [http://busjavka.ifrance.com/http-www-graffiti-it/index.html http www graffiti it stradivari photos] [http://child-ofadot.ifrance.com/il-walzer-dell.html il walzer dell allegria] [http://xxxenichkaa.ifrance.com/l-signorelli-flagellazione.html l signorelli flagellazione descrizione] [http://plyuh-vios.ifrance.com/ilona.html ilona] [http://angeljazz711.ifrance.com/i-don-t-wan-t.html i don t wan t to bag] [http://angeljazz711.ifrance.com/inventario-beni.html inventario beni disponibili] [http://busjavka.ifrance.com/hotel-helios/index.html hotel helios] [http://pupsik1993.ifrance.com/leonard.html leonard] [http://xxxenichkaa.ifrance.com/ljubi-mia-po-francuski.html ljubi mia po francuski] [http://cuivenarius.ifrance.com/homebreakers.html homebreakers] [http://taylors-acolyte.ifrance.com/irmak.html irmak] [http://alexandraa80.ifrance.com/life-goes-on/index.html life goes on 2pac] [http://pupsik1993.ifrance.com/lamartina.html lamartina] [http://starcross33.ifrance.com/letitia-casat/index.html letitia casat] [http://busjavka.ifrance.com/hai-scelto-me/index.html hai scelto me] [http://snakeystil.ifrance.com/jiuly/index.html jiuly] [http://listmishyk.ifrance.com/k700/index.html k700] [http://taylors-acolyte.ifrance.com/infradito.html infradito] [http://xxxenichkaa.ifrance.com/la-roca-del-moro-damablanca.html la roca del moro damablanca] [http://fluffy-mind.ifrance.com/karrie-anne-moss.html karrie anne moss] [http://alexandraa80.ifrance.com/la-figlia-del-re/index.html la figlia del re di castiglia] [http://eliasn5gh.ifrance.com/la-donna-nello-sport.html la donna nello sport storia] [http://snakeystil.ifrance.com/jeanni/index.html jeanni] [http://plyuh-vios.ifrance.com/i-consigli-di.html i consigli di bellezza di ovidio] [http://plyuh-vios.ifrance.com/incidenti-mortali.html incidenti mortali] [http://katzella.ifrance.com/halo-combat-evolved/index.html halo combat evolved] [http://taylors-acolyte.ifrance.com/ispettore-ambiente.html ispettore ambiente] [http://risdimpuka.ifrance.com/le-cose-in-comune/index.html le cose in comune] [http://carbonphoenix.ifrance.com/jeesus-kids.html jeesus kids] [http://snakeystil.ifrance.com/josh-groban/index.html josh groban] [http://angeljazz711.ifrance.com/immagini-di-capre.html immagini di capre] [http://oddonpurpose.ifrance.com/leonardo-manera.html leonardo manera] [http://plyuh-vios.ifrance.com/israel-kamakaw.html israel kamakaw] [http://snakeystil.ifrance.com/jara/index.html jara] [http://snakeystil.ifrance.com/juliana-bb4/index.html juliana bb4] [http://pupsik1993.ifrance.com/lisa-marie.html lisa marie] [http://katzella.ifrance.com/halleb/index.html halleb] [http://alexandraa80.ifrance.com/la-clori/index.html la clori] [http://pupsik1993.ifrance.com/la-vita.html la vita] [http://child-ofadot.ifrance.com/istruzioni-per.html istruzioni per dragon cam] [http://risdimpuka.ifrance.com/labirinto/index.html labirinto] [http://oddonpurpose.ifrance.com/mamma-insegname.html mamma insegname a ballar] [http://busjavka.ifrance.com/huevos-cartoons/index.html huevos cartoons] [http://eliasn5gh.ifrance.com/lo-strani-percorso.html lo strani percorso] [http://fluffy-mind.ifrance.com/koronati-charter.html koronati charter] [http://snakeystil.ifrance.com/jam-eddy-watta/index.html jam eddy watta] [http://child-ofadot.ifrance.com/immagini-lupa-di-roma.html immagini lupa di roma] [http://thecrownless.ifrance.com/idris-1-re-di-libia/index.html idris 1 re di libia] [http://thecrownless.ifrance.com/inno-firentina/index.html inno firentina] [http://oddonpurpose.ifrance.com/lil-eddie.html lil eddie] [http://plyuh-vios.ifrance.com/italiandreams-org.html italiandreams org] [http://listmishyk.ifrance.com/kati-eho-pathi/index.html kati eho pathi me ta matia sou] [http://eliasn5gh.ifrance.com/lu-colombo-and.html lu colombo and maracaibo] [http://eliasn5gh.ifrance.com/locali-gay.html locali gay] [http://busjavka.ifrance.com/hajuci/index.html hajuci] [http://risdimpuka.ifrance.com/lu-maritiell/index.html lu maritiell] [http://eliasn5gh.ifrance.com/la-sera-dei.html la sera dei miracoli] [http://carbonphoenix.ifrance.com/juguetibici.html juguetibici] [http://starcross33.ifrance.com/la-bambola-mp3/index.html la bambola mp3] [http://risdimpuka.ifrance.com/left-uot-side-alone/index.html left uot side alone] [http://plyuh-vios.ifrance.com/indirizzo-the.html indirizzo the rasmus] [http://snakeystil.ifrance.com/just-because/index.html just because you feel good] [http://alexandraa80.ifrance.com/ludacris-act-afool/index.html ludacris act afool] [http://busjavka.ifrance.com/hotel-voucher-conferma/index.html hotel voucher conferma holiday inn garde] [http://carbonphoenix.ifrance.com/jazzsamba.html jazzsamba] [http://child-ofadot.ifrance.com/interraziali.html interraziali] [http://pupsik1993.ifrance.com/lavoro-fvg.html lavoro fvg] [http://alexandraa80.ifrance.com/lamega98-3/index.html lamega98 3] [http://taylors-acolyte.ifrance.com/imagination.html imagination] [http://alexandraa80.ifrance.com/londra-a-capodanno/index.html londra a capodanno] [http://oddonpurpose.ifrance.com/luca-derisio.html luca derisio] [http://angeljazz711.ifrance.com/it-s-good-to-be.html it s good to be love] [http://child-ofadot.ifrance.com/immagini-per.html immagini per innamorati] [http://eliasn5gh.ifrance.com/lo-zingaro-felice-alex.html lo zingaro felice alex britti] [http://pupsik1993.ifrance.com/letti-cosatto.html letti cosatto] [http://xxxenichkaa.ifrance.com/la-canzone-dell.html la canzone dell ex di eamon] [http://xxxenichkaa.ifrance.com/lettere-didle.html lettere didle] [http://cuivenarius.ifrance.com/hombres-g-en-la.html hombres g en la playa] [http://chasingspaces.ifrance.com/hallo-lupen/index.html hallo lupen] [http://eliasn5gh.ifrance.com/lmc-materiale-composito.html lmc materiale composito] [http://alexandraa80.ifrance.com/lorellacuccarini/index.html lorellacuccarini] [http://eliasn5gh.ifrance.com/lilla-nigro-bloggo.html lilla nigro bloggo] [http://risdimpuka.ifrance.com/la-miss-perde-lo-slip/index.html la miss perde lo slip] [http://plyuh-vios.ifrance.com/ismaelserrano.html ismaelserrano] [http://katzella.ifrance.com/istria-rovigni/index.html istria rovigni] [http://taylors-acolyte.ifrance.com/ipofisi.html ipofisi] {{task}}
{{task}}


Using two Arrays of equal length, create a Hash object where the elements from on array (the keys) are linked to the elements of the other (the values)
Using two Arrays of equal length, create a Hash object where the elements from on array (the keys) are linked to the elements of the other (the values)
Line 44: Line 44:
end loop;
end loop;
for I in Key_List'range loop
for I in Key_List'range loop
Ada.Text_Io.Put_Line(To_String(Key_List(I)) & " => " &
Ada.Text_Io.Put_Line(To_String(Key_List(I))
To_String(Hash.Element(Key_List(I))));
end loop;
end Hash_Map_Test;

==[[C plus plus|C++]]==
[[Category:C plus plus]]
By strict definition a std::map is not a hash, but it provides the same functionality (but note that some C++ has hash sets too).

'''Compiler:''' g++ 4.0.2

#include <map>
#include <string>
int
main( int argc, char* argv[] )
{
std::string keys[] = { "1", "2", "3" } ;
std::string vals[] = { "a", "b", "c" } ;
std::map< std::string, std::string > hash ;
for( int i = 0 ; i < 3 ; i++ )
{
hash[ keys[i] ] = vals[i] ;
}
}

Alternatively:
#include <map> // for std::map
#include <algorithm> // for std::transform
#include <string> // for std::string
#include <utility> // for std::make_pair
int main()
{
std::string keys[] = { "one", "two", "three" };
std::string vals[] = { "foo", "bar", "baz" };
std::map<std::string, std::string> hash;
std::transform(keys, keys+3,
vals,
std::inserter(hash, hash.end()),
std::make_pair<std::string, std::string>);
}

==[[C sharp|C#]]==
[[Category:C sharp]]
System.Collections.HashTable h = new System.Collections.HashTable();
string[] arg_keys = {"foo","bar","val"};
string[] arg_values = {"little", "miss", "muffet"};
//Some basic error checking
int arg_length = 0;
if ( arg_keys.Length == arg_values.Length ) {
arg_length = arg_keys.Length;
}
for( int i = 0; i < arg_length; i++ ){
h.add( arg_keys[i], arg_values[i] );
}

Alternate way of adding values

for( int i = 0; i < arg_length; i++ ){
h[ arg_keys[i] ] = arg_values[i];
}

==[[D]]==
[[Category:D]]

char[][] keys = ["one", "two", "three"]
int[] values = [1, 2, 3];
int[char[]] hash;
foreach(i,k; keys)
hash[k] = values[i];
==[[E]]==
[[Category:E]]

def keys := ["one", "two", "three"]
def values := [1, 2, 3]
__makeMap.fromColumns(keys, values)

==[[Haskell]]==
[[Category:Haskell]]
'''Interpreter:''' [[GHC|GHCi]] 6.6
import Data.Map
makeMap ks vs = fromList $ zip ks vs
mymap = makeMap ['a','b','c'] [1,2,3]

==[[JavaScript]]==
[[Category:JavaScript]]

var keys = ['a', 'b', 'c'];
var values = [1, 2, 3];
var map = {};
for(var i in keys) {
map[ keys[i] ] = values[i];
}


==[[OCaml]]==
[[Category:OCaml]]
The idiomatic solution uses lists rather than arrays.

let keys = [ "foo"; "bar"; "baz" ]
and vals = [ 16384; 32768; 65536 ]
and hash = Hashtbl.create 0;;

List.iter2 (Hashtbl.add hash) keys vals;;

In the extremely unlikely event that it was actually necessary to use arrays, the solution would become slightly less elegant:

let keys = [| "foo"; "bar"; "baz" |]
and vals = [| 16384; 32768; 65536 |]
and hash = Hashtbl.create 0;;

for i = 0 to Array.length keys - 1 do
Hashtbl.add hash keys.(i) vals.(i)
done;;

In either case, an exception is raised if the inputs are different lengths.

==[[Perl]]==
[[Category:Perl]]
'''Interpreter:''' [[Perl]] 5
use List::MoreUtils qw(zip);
my @keys = qw(a b c);
my @vals = (1, 2, 3);
my %hash = zip @keys, @vals;
Using no modules:
my %hash;
@hash{qw(a b c)} = (1, 2, 3);

==[[PHP]]==

[[Category:PHP]]

PHP 5:
$keys = array('a', 'b', 'c');
$values = array(1, 2, 3);
$hash = array_combine($keys, $values);

PHP 4:
$keys = array('a', 'b', 'c');
$values = array(1, 2, 3);
$hash = array();
for ($idx = 0; $idx < count($keys); $idx++) {
$hash[$keys[$idx]] = $values[$idx];
}

==[[Pop11]]==
[[Category:Pop11]]

vars keys = { 1 a b c};
vars vals = { 2 3 valb valc};
vars i;
;;; Create hash table
vars ht = newmapping([], 500, 0, true);
;;; Loop over input arrays (vectors)
for i from 1 to length(keys) do
vals(i) -> ht(keys(i));
endfor;

==[[Python]]==

[[Category:Python]]
'''Interpreter:''' [[Python]] 2.5
<pre>
keys = ['a', 'b', 'c']
values = [1, 2, 3]
hash = dict(zip(keys, values))

# Lazily:
from itertools import izip
hash = dict(izip(keys, values))
</pre>

==[[Ruby]]==
[[Category:Ruby]]
keys=['hal',666,[1,2,3]]
vals=['ibm','devil',123]
hash = Hash[*keys.zip(vals).flatten]
# now hash => {'hal' => 'ibm', 666 => 'devil', [1,2,3] => 123}

#retrieve the value linked to the key [1,2,3]
puts hash[ [1,2,3] ]
#123

== [[Scala]] ==
[[Category:Scala]]
val keys = Array(1, 2, 3)
val values = Array("A", "B", "C")
val map = Map(keys.zip(values) : _*)
// returns Map(1 -> "A", 2 -> "B", 3 -> "C")
// keys.zip(values) is an array of pairs : Array({1, "A"}, {2, "B"}, {3, "C"})
// Map(...) expects multiple pairs arguments. Syntax ": _*" tells the single argument contains multiple values.

== [[Tcl]] ==
[[Category:Tcl]]

Arrays in Tcl are automatically associative, i.e. there are no "not hashed arrays". If we can take "arrays of equal length" to mean "<i>lists</i> of equal length", then the task might look like this:

set keys [list fred bob joe]
set values [list barber plumber tailor]
array set arr {}
foreach a $keys b $values { set $arr($a) $b }

Revision as of 21:47, 31 August 2007

love philosophy himno a quito hitparade its not easy hells kitchen original soundtrack hotel la giada latte per neonati miltina la decapitazione dell ostaggio io ho te audio2 lotto di milano leslie amine liefdeskapitein lesli et amin heresy mondavio la donna riccia modugno hilary dutf has tabulas verres abstulit lee ryan why me inno spagnolo score irdeto plugin skystar 2 jamás il magnate greco kemal malovcic midi la valle dell eden la panthere rose la quindicesima epistola juan alfonso baptista hagen nina letr de hoobastank i consigli un pirla ighina it kisses of no return isola del tesoro kobra inviati di uno mattina lepoglava hotel altavilla spello immagini del giappone leggi industria della carta lovefool the cardigans katie holmes nuda la bigate luca di rio la 2 gurra mondiale here whitout you here with me dido kenya lionel richie testo angel in the middle sugababes hea haïduci luna by verdena il barone brigate rossonere letteratura trecentesca locandina film vanilla sky tom cruise greased lightning istanbul kimsun il tirreno del 1 08 04 la citta e pulcinella hp 635 liquet lose weight by jucing galimberti nino jesi invio sms gratuito love come again laura gemser kurt waill inno al trentino kilye minogue laura pasuini la vittoria di kuca hrvatska korcula jose antonio bordell kassandra la nina la pinta e la santa maria ja sei na morar tribalistas homevideo industrie mobili los panchos il potere insieme mina legge 449 immagini xxx k9 indirizzi a parma lloyd ft ashanti konkretna piosenka hotels taormina lee rayan fotos xx la mer kinsky lotr la nascita del lavoro hej ljubavi u dalekom gradu lambada mmf italo music lotto corriere kristaallen internet italiana kir2kos kaspar kapparoni istituto nazionale urbanistica ibarra k448 mozart luigi xv ho capito che ti amo luigi tenco il gladiatore free midi laura corradin karaoke vecchioni lingua francese pisa kily jordan peele jay z i beyonce http www graffiti it stradivari photos il walzer dell allegria l signorelli flagellazione descrizione ilona i don t wan t to bag inventario beni disponibili hotel helios leonard ljubi mia po francuski homebreakers irmak life goes on 2pac lamartina letitia casat hai scelto me jiuly k700 infradito la roca del moro damablanca karrie anne moss la figlia del re di castiglia la donna nello sport storia jeanni i consigli di bellezza di ovidio incidenti mortali halo combat evolved ispettore ambiente le cose in comune jeesus kids josh groban immagini di capre leonardo manera israel kamakaw jara juliana bb4 lisa marie halleb la clori la vita istruzioni per dragon cam labirinto mamma insegname a ballar huevos cartoons lo strani percorso koronati charter jam eddy watta immagini lupa di roma idris 1 re di libia inno firentina lil eddie italiandreams org kati eho pathi me ta matia sou lu colombo and maracaibo locali gay hajuci lu maritiell la sera dei miracoli juguetibici la bambola mp3 left uot side alone indirizzo the rasmus just because you feel good ludacris act afool hotel voucher conferma holiday inn garde jazzsamba interraziali lavoro fvg lamega98 3 imagination londra a capodanno luca derisio it s good to be love immagini per innamorati lo zingaro felice alex britti letti cosatto la canzone dell ex di eamon lettere didle hombres g en la playa hallo lupen lmc materiale composito lorellacuccarini lilla nigro bloggo la miss perde lo slip ismaelserrano istria rovigni ipofisi

Task
Hash from two arrays
You are encouraged to solve this task according to the task description, using any language you may know.

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

Ada

Compiler: GNAT GPL 2007

with Ada.Strings.Hash;
with Ada.Containers.Hashed_Maps;
with Ada.Text_Io;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

procedure Hash_Map_Test is
   function Equivalent_Key (Left, Right : Unbounded_String) return Boolean is
   begin
      return Left = Right;
   end Equivalent_Key;
  
   function Hash_Func(Key : Unbounded_String) return Ada.Containers.Hash_Type is
   begin
      return Ada.Strings.Hash(To_String(Key));
   end Hash_Func;
  
   package My_Hash is new Ada.Containers.Hashed_Maps(Key_Type => Unbounded_String,
      Element_Type => Unbounded_String,
      Hash => Hash_Func,
      Equivalent_Keys => Equivalent_Key);
     
   type String_Array is array(Positive range <>) of Unbounded_String;
     
   Hash : My_Hash.Map;
   Key_List : String_Array := (To_Unbounded_String("foo"), 
      To_Unbounded_String("bar"),
      To_Unbounded_String("val"));
     
   Element_List : String_Array := (To_Unbounded_String("little"), 
      To_Unbounded_String("miss"), 
      To_Unbounded_String("muffet"));
     
begin
   for I in Key_List'range loop
      Hash.Insert(Key => (Key_List(I)),
         New_Item => (Element_List(I)));
   end loop;
   for I in Key_List'range loop
      Ada.Text_Io.Put_Line(To_String(Key_List(I))