Hash from two arrays: Difference between revisions
Content added Content deleted
(→{{header|Diego}}: Added Diego entry) |
|||
Line 824: | Line 824: | ||
c 3 |
c 3 |
||
</pre> |
</pre> |
||
=={{header|Diego}}== |
|||
Diego has in-built <code>hash</code> and <code>dict</code> (short for 'dictionary') objects which function the same, except <code>hash</code> can only accept uuid datatypes for keys. Diego also has <code>_hash</code> verb, used to hash an object. |
|||
<lang diego>use_namespace(rosettacode)_me(); |
|||
add_ary(keysDict)_values(a,b,c); |
|||
add_ary(valsDict)_values(1,2,3); |
|||
add_dict(aDict)_map([keysDict],[valsDict]); |
|||
add_hash(aHash)_hash[valsDict]; // Keys will be new uuids |
|||
reset_namespace[];</lang> |
|||
Arrays can manually be mapped from two arrays using a <code>_for</code> posit, for instance: |
|||
<lang diego>use_namespace(rosettacode)_me(); |
|||
add_dict(bDict); |
|||
add_dict(cDict); |
|||
add_for(i)_from(0)_lessthan()_[keysDict]_length()_inc() |
|||
with_dict(bDict)_mapkeys()_[keysDict]_at[i]_mapvals()_[valsDict]_at[i]; |
|||
[cDict]_map()_[keysDict]_at[i]_[valsDict]_at[i]; // alternative shortened syntax |
|||
; |
|||
reset_namespace[];</lang> |
|||
=={{header|E}}== |
=={{header|E}}== |
||