Anonymous user
Hash from two arrays: Difference between revisions
m
→{{header|REXX}}: allowed multiple hash keys to point to a particular value.
m (→{{header|REXX}}: added whitespace and changed comments, used a template for the output section..) |
m (→{{header|REXX}}: allowed multiple hash keys to point to a particular value.) |
||
Line 1,466:
=={{header|REXX}}==
This REXX version allows multiple keys for a value, the keys are case sensitive.
<lang rexx>/*REXX program demonstrates hashing of a stemmed array (from a key
vals= 'triangle quadrilateral pentagon hexagon heptagon octagon nonagon decagon dodecagon'
key.2='three four five six seven eight nine ten
key.4='III IV V VI VII VIII IX X XII'
key.5='iii iv v vi vii viii ix x xii'
hash.='───(not defined)───' /* [↑] blanks added to humorous keys */
/* just because it looks prettier.*/
do k=1 while key.k\==''
▲call hash vals,keys /*hash the keys to the values. */
call hash vals,key.k /*hash the keys to the values. */
end /*k*/
parse arg query . /*obtain what was specified on the C.L.*/
if query=='' then exit /*Nothing? Then leave Dodge City. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
hash:
do j=1
hash.map= word(
end /*j*/
return</lang>
{{out|output|text= when using the
<pre>
key: phive value: pentagon
</pre>
{{out|output|text= when using the input value of: <tt> dingsta </tt>}}
<pre>
key: dingsta value: ───(not defined)───
</pre>
|