Hash from two arrays: Difference between revisions

From Rosetta Code
Content added Content deleted
mNo edit summary
Line 1: Line 1:
[http://sneezingpops.110mb.com/samsung-htup/ samsung htup30] [http://forever-your.110mb.com/data/giuseppe-quelli.htm giuseppe quelli che il calcio] [http://some-omeelse.110mb.com/data/immagini-da.htm immagini da energy airforce aim strike] [http://mouse-zae.110mb.com/onkyo-tx.htm onkyo tx 702] [http://ultra-creator.110mb.com/articles/clim.htm clim] [http://book-wench.110mb.com/text/calendario-valeria/ calendario valeria marini 2005] [http://lazythoughts.110mb.com/lib/mitico/ mitico] [http://some-omeelse.110mb.com/data/wish-you.htm wish you were here pink floyd] [http://stitchesnglue.110mb.com/hoobastank-the.htm hoobastank the reason lyric] [http://slavkamolot.110mb.com/library/personaggi-famosi/ personaggi famosi da piccoli] [http://trene-von-anty.110mb.com/description/www-iniziopartita.htm www iniziopartita it] [http://stitchesnglue.110mb.com/donne-porno.htm donne porno star vecchie] [http://slavkamolot.110mb.com/library/harry-potter/ harry potter e il prigioniero di] [http://dialed.110mb.com/small/elettricadanza/ elettricadanza] [http://trene-von-anty.110mb.com/description/conoscersi-org.htm conoscersi org] [http://book-wench.110mb.com/text/heliosnet-chat/ heliosnet chat] [http://funk-mastah-ion.110mb.com/data/silkwood.htm silkwood] [http://forever-your.110mb.com/data/river.htm river] [http://gekijuls.110mb.com/crepuscolo-di/ crepuscolo di gloria] [http://slavkamolot.110mb.com/library/samsung/ samsung 800] [http://ultra-creator.110mb.com/articles/nagaoka.htm nagaoka] [http://nationavce.110mb.com/view/helly-hansen.htm helly hansen] [http://ultra-creator.110mb.com/articles/kingston-mb.htm kingston 128mb pen] [http://some-omeelse.110mb.com/data/il-metronomo.htm il metronomo] [http://olikka.110mb.com/library/jessica-alba.htm jessica alba nua] [http://mouse-zae.110mb.com/phil-collins.htm phil collins both sides] [http://funk-mastah-ion.110mb.com/data/michelangelo-usb.htm michelangelo usb c] [http://blue-olusha.110mb.com/library/merina/ merina] [http://mouse-zae.110mb.com/bmw-lt.htm bmw lt] [http://nationavce.110mb.com/view/palamau.htm palamau] [http://trouble166.110mb.com/culle.htm culle] [http://sister-sunshine.110mb.com/html/magasa/ magasa] [http://funk-mastah-ion.110mb.com/data/denton-usa.htm denton (usa)] [http://yeeden.110mb.com/data/iss-pro/ iss pro 2] [http://sister-sunshine.110mb.com/html/bloccato/ bloccato] [http://gekijuls.110mb.com/restauro/ restauro] [http://sister-sunshine.110mb.com/html/flipflops/ flipflops] [http://some-omeelse.110mb.com/data/nessuno-articolo.htm nessuno articolo 31] [http://dialed.110mb.com/small/nuovo-filmato/ nuovo filmato per crimson tears] [http://stitchesnglue.110mb.com/inside-microsoft.htm inside microsoft visual studio net 2003] [http://blue-olusha.110mb.com/library/viaggi-in/ viaggi in pulman] [http://yeeden.110mb.com/data/hard-disk/ hard disk esterno 60gb] [http://nationavce.110mb.com/view/dizionario-ialiano.htm dizionario ialiano rumeno] [http://gekijuls.110mb.com/download-musica/ download musica classica] [http://stitchesnglue.110mb.com/palmare-ipaq.htm palmare ipaq rx3715] [http://sister-sunshine.110mb.com/html/iss-millennium/ iss millennium] [http://ultra-creator.110mb.com/articles/condizionatori-fissi.htm condizionatori fissi con pompa di calore] [http://trouble166.110mb.com/simplythebest.htm simplythebest] [http://ultra-creator.110mb.com/articles/hard-disk.htm hard disk esterni 250 gb] [http://unremig.110mb.com/birreria/ birreria] [http://sneezingpops.110mb.com/bischero/ bischero] [http://sneezingpops.110mb.com/calendario-controcampo/ calendario controcampo 2005] [http://sister-sunshine.110mb.com/html/ibm-thinkpad/ ibm thinkpad celeron] [http://olikka.110mb.com/library/volo-napoli.htm volo napoli sharm el sheikh] [http://yeeden.110mb.com/data/fotone/ fotone] [http://mouse-zae.110mb.com/sales-force.htm sales force automation] [http://dialed.110mb.com/small/albergo-madrid/ albergo madrid centro] [http://trene-von-anty.110mb.com/description/la-historia.htm la historia de la nba] [http://gekijuls.110mb.com/xradio-com/ x4radio com] [http://dialed.110mb.com/small/pamelita-com/ pamelita com] [http://mouse-zae.110mb.com/michelemma.htm michelemma] [http://unremig.110mb.com/pannelli-system/ pannelli system srl] [http://sister-sunshine.110mb.com/html/amd/ amd 3000 754] [http://gekijuls.110mb.com/o-n/ o n a] [http://sneezingpops.110mb.com/poker-col/ poker col diavolo] [http://some-omeelse.110mb.com/data/annuncio-donna.htm annuncio donna single] [http://unremig.110mb.com/www-annunci/ www annunci] [http://mouse-zae.110mb.com/base-musicale.htm base musicale la gatta] [http://lazythoughts.110mb.com/lib/eleonora-di/ eleonora di miele] [http://gekijuls.110mb.com/lavoro-a/ lavoro a budapest] [http://nationavce.110mb.com/view/usb-.htm usb 1 gb mp3] [http://lazythoughts.110mb.com/lib/www-cdgirl/ www cdgirl com] [http://some-omeelse.110mb.com/data/superenalotto.htm superenalotto 3000] [http://some-omeelse.110mb.com/data/de-roud.htm de roud] [http://gekijuls.110mb.com/foto-aerei/ foto aerei] [http://some-omeelse.110mb.com/data/kodak-stampanti.htm kodak stampanti] [http://slavkamolot.110mb.com/library/te-piaciuta/ te piaciuta] [http://stitchesnglue.110mb.com/sexo-infantil.htm sexo infantil] [http://olikka.110mb.com/library/lavamat-clara.htm lavamat clara] [http://gekijuls.110mb.com/minier/ minier] [http://yeeden.110mb.com/data/colifornia/ colifornia] [http://sneezingpops.110mb.com/windows-xp/ windows xp cd key] [http://sneezingpops.110mb.com/amore-mio/ amore mio spogliati che poi ti spiego] [http://funk-mastah-ion.110mb.com/data/arte-del.htm arte del ricamo] [http://slavkamolot.110mb.com/library/fotos-de/ fotos de kirsten dust] [http://some-omeelse.110mb.com/data/benq-joybee.htm benq joybee 110 256mb] [http://ultra-creator.110mb.com/articles/incontri-annuncio.htm incontri annuncio veneto] [http://slavkamolot.110mb.com/library/www-venesuela/ www venesuela com] [http://sister-sunshine.110mb.com/html/enermax-csta/ enermax cs656ta] [http://trene-von-anty.110mb.com/description/www-lago.htm www lago com de] [http://slavkamolot.110mb.com/library/mondowrestling/ mondowrestling] [http://lazythoughts.110mb.com/lib/nokia-auricolare/ nokia auricolare] [http://trouble166.110mb.com/mammifero.htm mammifero] [http://mouse-zae.110mb.com/knocking-on.htm knocking on haven s door] [http://gekijuls.110mb.com/creazioni-regia/ creazioni regia oro srl] [http://blue-olusha.110mb.com/library/www-move/ www move drive com] [http://slavkamolot.110mb.com/library/libri-magia/ libri magia] [http://unremig.110mb.com/h-b/ h b drx430] [http://blue-olusha.110mb.com/library/atmasphere-music/ atmasphere music] [http://unremig.110mb.com/beer-thomas/ beer thomas] [http://trouble166.110mb.com/canzoni-it.htm canzoni it] [http://olikka.110mb.com/library/sarah-ferguson.htm sarah ferguson nuda] [http://nationavce.110mb.com/view/kj.htm kj] [http://yeeden.110mb.com/data/sito-ufficiale/ sito ufficiale valentino rossi] [http://olikka.110mb.com/library/moneta-romana.htm moneta romana] [http://dialed.110mb.com/small/emmental/ emmental] [http://book-wench.110mb.com/text/high/ high] [http://mouse-zae.110mb.com/generation-of.htm generation of chaos 4 sul web] [http://blue-olusha.110mb.com/library/sexualidad/ sexualidad] [http://lazythoughts.110mb.com/lib/clavame-tu/ clavame tu amor de kinky] [http://unremig.110mb.com/tdk-dvd/ tdk dvd videobox] [http://ultra-creator.110mb.com/articles/olimpus.htm olimpus 370] [http://blue-olusha.110mb.com/library/offerta-speciali/ offerta speciali hotel venezia] [http://yeeden.110mb.com/data/hotel-de/ hotel de palma palermo] [http://trouble166.110mb.com/dogs-and.htm dogs and lights] [http://dialed.110mb.com/small/color-experanza/ color experanza] [http://slavkamolot.110mb.com/library/gelsenkirchen/ gelsenkirchen] [http://gekijuls.110mb.com/www-alpine/ www alpine com] [http://sister-sunshine.110mb.com/html/base-musicali/ base musicali] [http://forever-your.110mb.com/data/king-diamond.htm king diamond] [http://forever-your.110mb.com/data/merida-hotel.htm merida hotel] [http://nationavce.110mb.com/view/accecare.htm accecare] [http://sister-sunshine.110mb.com/html/juegos-de/ juegos de pokemon de gameboy color] [http://unremig.110mb.com/petsamo/ petsamo] [http://stitchesnglue.110mb.com/mouse-logitech.htm mouse logitech ultrax optical] [http://sneezingpops.110mb.com/soundtrack/ soundtrack] [http://ultra-creator.110mb.com/articles/deskjet.htm deskjet 520] [http://sneezingpops.110mb.com/shape-shifters/ shape shifters lolas theme] [http://trouble166.110mb.com/ford-focus.htm ford focus 100 cv] [http://mouse-zae.110mb.com/total-ir.htm total ir remote] [http://nationavce.110mb.com/view/funerale-frasi.htm funerale frasi] [http://yeeden.110mb.com/data/entombed-monkey/ entombed monkey puss live in london] [http://gekijuls.110mb.com/cypress-hill/ cypress hill still smokin] [http://gekijuls.110mb.com/t-come/ t come tango] [http://book-wench.110mb.com/text/open-gate/ open gate] [http://blue-olusha.110mb.com/library/klimt/ klimt 1918] [http://sneezingpops.110mb.com/mp-maroon/ mp3 maroon 5] [http://slavkamolot.110mb.com/library/i-frenetici/ i frenetici] [http://olikka.110mb.com/library/over-cinquanta.htm over cinquanta] [http://stitchesnglue.110mb.com/corinne-clery.htm corinne clery] [http://forever-your.110mb.com/data/box-esterno.htm box esterno hard disk] [http://yeeden.110mb.com/data/frona/ frona] [http://funk-mastah-ion.110mb.com/data/riassunto-elsa.htm riassunto elsa morante] [http://lazythoughts.110mb.com/lib/generali-assicurazione/ generali assicurazione] [http://gekijuls.110mb.com/capcom-vs/ capcom vs snk millennium fight 2000] [http://stitchesnglue.110mb.com/reggiseno-molto.htm reggiseno molto imbottito] [http://funk-mastah-ion.110mb.com/data/luna-de.htm luna de miel] [http://trene-von-anty.110mb.com/description/hp-.htm hp 2100 c4096a] [http://sneezingpops.110mb.com/vip-scandal/ vip scandal] [http://trouble166.110mb.com/de-angelis.htm de angelis midi] [http://yeeden.110mb.com/data/gyllene-tider/ gyllene tider] [http://olikka.110mb.com/library/locali-noturni.htm locali noturni] [http://mouse-zae.110mb.com/immagini-e.htm immagini e clip art gratuite] [http://unremig.110mb.com/olimpus-p/ olimpus p10] [http://forever-your.110mb.com/data/cerca-azienda.htm cerca azienda] [http://olikka.110mb.com/library/ricetta-insalata.htm ricetta insalata di riso] [http://gekijuls.110mb.com/hotel-budapest/ hotel budapest] [http://funk-mastah-ion.110mb.com/data/bachay.htm bachay] [http://slavkamolot.110mb.com/library/occasione-moto/ occasione moto] [http://dialed.110mb.com/small/ninnananna/ ninnananna] [http://slavkamolot.110mb.com/library/bfbs-key/ bfbs key] [http://ultra-creator.110mb.com/articles/bubble-games.htm bubble games] [http://book-wench.110mb.com/text/elaborazioni-estetiche/ elaborazioni estetiche] [http://funk-mastah-ion.110mb.com/data/u-cover.htm u2 cover night and day i think of you] [http://ultra-creator.110mb.com/articles/nba.htm nba 2004] [http://trouble166.110mb.com/depeche-mode.htm depeche mode personal jesus] [http://funk-mastah-ion.110mb.com/data/dlink-wifi.htm dlink wifi] [http://some-omeelse.110mb.com/data/xbox-memoria.htm xbox memoria accessori console] [http://blue-olusha.110mb.com/library/sigma/ sigma 24 70] [http://gekijuls.110mb.com/nikc/ nikc] [http://ultra-creator.110mb.com/articles/paddy-kelly.htm paddy kelly] [http://dialed.110mb.com/small/arrog/ arrog] [http://some-omeelse.110mb.com/data/motorola-ch.htm motorola ch] [http://unremig.110mb.com/samsung-/ samsung 32 pollici] [http://blue-olusha.110mb.com/library/in-to/ in to my arms] [http://slavkamolot.110mb.com/library/la-spada/ la spada e la rosa] [http://funk-mastah-ion.110mb.com/data/supporto-auto.htm supporto auto s100] [http://yeeden.110mb.com/data/ricevitore-accessori/ ricevitore accessori gps] [http://forever-your.110mb.com/data/fotografia-de.htm fotografia de mujeres negras de africa] [http://blue-olusha.110mb.com/library/camus/ camus] [http://trouble166.110mb.com/m-polar.htm m63 polar] [http://gekijuls.110mb.com/i-would/ i would you feel] [http://forever-your.110mb.com/data/pentax-optio.htm pentax optio 50 s] [http://mouse-zae.110mb.com/angel-ml.htm angel 50ml] [http://blue-olusha.110mb.com/library/crash-wafer/ crash wafer] [http://stitchesnglue.110mb.com/foto-gratis.htm foto gratis donne playboy] [http://blue-olusha.110mb.com/library/jens-o/ jens o] [http://sister-sunshine.110mb.com/html/spedizione-everest/ spedizione everest] [http://book-wench.110mb.com/text/mrty/ mrty] [http://blue-olusha.110mb.com/library/batterie-np/ batterie np 200] [http://unremig.110mb.com/climatizzatore-parete/ climatizzatore parete] [http://gekijuls.110mb.com/oh-mi/ oh mi carolina] [http://slavkamolot.110mb.com/library/waterslide-slalom/ waterslide slalom] [http://sister-sunshine.110mb.com/html/scanner/ scanner 4000] [http://gekijuls.110mb.com/auto-microcar/ auto microcar] [http://stitchesnglue.110mb.com/hys.htm hys] [http://unremig.110mb.com/mobili-roma/ mobili roma] [http://mouse-zae.110mb.com/yonca-evcimik.htm yonca evcimik] [http://book-wench.110mb.com/text/modem-adsl/ modem adsl usb d link] [http://stitchesnglue.110mb.com/foto-su.htm foto su nelson dida] {{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)


==[[C plus plus|C++]]==
==[[C plus plus|C ]]==
[[Category:C plus plus]]
[[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).
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
'''Compiler:''' g 4.0.2


#include <map>
#include <map>
Line 20: Line 20:
std::map< std::string, std::string > hash ;
std::map< std::string, std::string > hash ;
for( int i = 0 ; i < 3 ; i++ )
for( int i = 0 ; i < 3 ; i )
{
{
hash[ keys[i] ] = vals[i] ;
hash[ keys[i] ] = vals[i] ;
Line 39: Line 39:
std::map<std::string, std::string> hash;
std::map<std::string, std::string> hash;
std::transform(keys, keys+3,
std::transform(keys, keys 3,
vals,
vals,
std::inserter(hash, hash.end()),
std::inserter(hash, hash.end()),
Line 58: Line 58:
}
}
for( int i = 0; i < arg_length; i++ ){
for( int i = 0; i < arg_length; i ){
h.add( arg_keys[i], arg_values[i] );
h.add( arg_keys[i], arg_values[i] );
}
}
Line 64: Line 64:
Alternate way of adding values
Alternate way of adding values


for( int i = 0; i < arg_length; i++ ){
for( int i = 0; i < arg_length; i ){
h[ arg_keys[i] ] = arg_values[i];
h[ arg_keys[i] ] = arg_values[i];
}
}
Line 151: Line 151:
$values = array(1, 2, 3);
$values = array(1, 2, 3);
$hash = array();
$hash = array();
for ($idx = 0; $idx < count($keys); $idx++) {
for ($idx = 0; $idx < count($keys); $idx ) {
$hash[$keys[$idx]] = $values[$idx];
$hash[$keys[$idx]] = $values[$idx];
}
}

Revision as of 18:39, 25 August 2007

samsung htup30 giuseppe quelli che il calcio immagini da energy airforce aim strike onkyo tx 702 clim calendario valeria marini 2005 mitico wish you were here pink floyd hoobastank the reason lyric personaggi famosi da piccoli www iniziopartita it donne porno star vecchie harry potter e il prigioniero di elettricadanza conoscersi org heliosnet chat silkwood river crepuscolo di gloria samsung 800 nagaoka helly hansen kingston 128mb pen il metronomo jessica alba nua phil collins both sides michelangelo usb c merina bmw lt palamau culle magasa denton (usa) iss pro 2 bloccato restauro flipflops nessuno articolo 31 nuovo filmato per crimson tears inside microsoft visual studio net 2003 viaggi in pulman hard disk esterno 60gb dizionario ialiano rumeno download musica classica palmare ipaq rx3715 iss millennium condizionatori fissi con pompa di calore simplythebest hard disk esterni 250 gb birreria bischero calendario controcampo 2005 ibm thinkpad celeron volo napoli sharm el sheikh fotone sales force automation albergo madrid centro la historia de la nba x4radio com pamelita com michelemma pannelli system srl amd 3000 754 o n a poker col diavolo annuncio donna single www annunci base musicale la gatta eleonora di miele lavoro a budapest usb 1 gb mp3 www cdgirl com superenalotto 3000 de roud foto aerei kodak stampanti te piaciuta sexo infantil lavamat clara minier colifornia windows xp cd key amore mio spogliati che poi ti spiego arte del ricamo fotos de kirsten dust benq joybee 110 256mb incontri annuncio veneto www venesuela com enermax cs656ta www lago com de mondowrestling nokia auricolare mammifero knocking on haven s door creazioni regia oro srl www move drive com libri magia h b drx430 atmasphere music beer thomas canzoni it sarah ferguson nuda kj sito ufficiale valentino rossi moneta romana emmental high generation of chaos 4 sul web sexualidad clavame tu amor de kinky tdk dvd videobox olimpus 370 offerta speciali hotel venezia hotel de palma palermo dogs and lights color experanza gelsenkirchen www alpine com base musicali king diamond merida hotel accecare juegos de pokemon de gameboy color petsamo mouse logitech ultrax optical soundtrack deskjet 520 shape shifters lolas theme ford focus 100 cv total ir remote funerale frasi entombed monkey puss live in london cypress hill still smokin t come tango open gate klimt 1918 mp3 maroon 5 i frenetici over cinquanta corinne clery box esterno hard disk frona riassunto elsa morante generali assicurazione capcom vs snk millennium fight 2000 reggiseno molto imbottito luna de miel hp 2100 c4096a vip scandal de angelis midi gyllene tider locali noturni immagini e clip art gratuite olimpus p10 cerca azienda ricetta insalata di riso hotel budapest bachay occasione moto ninnananna bfbs key bubble games elaborazioni estetiche u2 cover night and day i think of you nba 2004 depeche mode personal jesus dlink wifi xbox memoria accessori console sigma 24 70 nikc paddy kelly arrog motorola ch samsung 32 pollici in to my arms la spada e la rosa supporto auto s100 ricevitore accessori gps fotografia de mujeres negras de africa camus m63 polar i would you feel pentax optio 50 s angel 50ml crash wafer foto gratis donne playboy jens o spedizione everest mrty batterie np 200 climatizzatore parete oh mi carolina waterslide slalom scanner 4000 auto microcar hys mobili roma yonca evcimik modem adsl usb d link foto su nelson dida

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)

C

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#

 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

char[][] keys = ["one", "two", "three"]
int[] values  = [1, 2, 3];

int[char[]] hash;

foreach(i,k; keys)
 hash[k] = values[i];

E

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

Haskell

Interpreter: GHCi 6.6

import Data.Map

makeMap ks vs = fromList $ zip ks vs
mymap = makeMap ['a','b','c'] [1,2,3]

JavaScript

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


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

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

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

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

Interpreter: Python 2.5

keys = ['a', 'b', 'c']
values = [1, 2, 3]
hash = dict(zip(keys, values))

# Lazily:
from itertools import izip
hash = dict(izip(keys, values))

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

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

Arrays in Tcl are automatically associative, i.e. there are no "not hashed arrays". If we can take "arrays of equal length" to mean "lists 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 }