Hash from two arrays: Difference between revisions

Added XPL0 example.
m (→‎{{header|Wren}}: Changed to Wren S/H)
(Added XPL0 example.)
Line 2,702:
<pre>
{2: second, 1: first, 3: third, 5: fifth, 4: fourth}
</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">func Code(Str); \Return a simple, perfect hash code for the Keys used here
char Str;
return Str(2) & 7;
 
int Keys, Values, I, Hash(8);
[Keys:= ["first", "second", "third", "fourth", "fifth", "sixth"];
Values:= [1, 2, 3, 4, 5, 6];
for I:= 0 to 6-1 do
Hash(Code(Keys(I))):= Values(I);
IntOut(0, Hash(Code("second"))); CrLf(0);
IntOut(0, Hash(Code("sixth"))); CrLf(0);
]</syntaxhighlight>
{{out}}
<pre>
2
6
</pre>
 
295

edits