Hash from two arrays: Difference between revisions

Content added Content deleted
(Added Yabasic)
Line 1,303: Line 1,303:
=={{header|langur}}==
=={{header|langur}}==
=== the easy way ===
=== the easy way ===
<syntaxhighlight lang="langur">writeln(hash w/a b c d/, [1, 2, 3, 4])</syntaxhighlight>
<syntaxhighlight lang="langur">writeln(hash fw/a b c d/, [1, 2, 3, 4])
</syntaxhighlight>


Note that w/a b c d/ is a semantic convenience equivalent to ["a", "b", "c", "d"].
Note that fw/a b c d/ is a semantic convenience equivalent to ["a", "b", "c", "d"].


=== a longer way ===
=== a longer way ===
Using the append operator would silently overwrite hash values for matching keys, but the more() function will not.
Using the append operator would silently overwrite hash values for matching keys, but the more() function will not.
<syntaxhighlight lang="langur">val .new = foldfrom(
<syntaxhighlight lang="langur">val .new = foldfrom(
f(.hash, .key, .value) more .hash, h{.key: .value},
fn(.hash, .key, .value) more .hash, h{.key: .value},
h{}, w/a b c d/, [1, 2, 3, 4],
h{}, fw/a b c d/, [1, 2, 3, 4],
)
)