Hash from two arrays: Difference between revisions
Content added Content deleted
(Added Yabasic) |
Langurmonkey (talk | contribs) |
||
Line 1,303: | Line 1,303: | ||
=={{header|langur}}== |
=={{header|langur}}== |
||
=== the easy way === |
=== the easy way === |
||
<syntaxhighlight lang="langur">writeln(hash |
<syntaxhighlight lang="langur">writeln(hash fw/a b c d/, [1, 2, 3, 4]) |
||
</syntaxhighlight> |
|||
Note that |
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( |
||
fn(.hash, .key, .value) more .hash, h{.key: .value}, |
|||
h{}, |
h{}, fw/a b c d/, [1, 2, 3, 4], |
||
) |
) |
||