Create dict: Difference between revisions
Content added Content deleted
(uniqueness of keys) |
("Better category ordering, add redirects to categories, fix pseudo-adverb categories") |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{primitive|x!y}} |
{{primitive|.x<br>x!y}} |
||
The '''create dict''' primitive, a.k.a. '''map''' |
The '''create dict''' primitive, a.k.a. '''map''' converts its argument(s) to a dictionary. |
||
==== K3 ==== |
|||
Takes a an array of pairs and converts it to a dictionary. |
|||
<pre> |
|||
.((`a;10);(`b;20)) |
|||
.((`a;10;) |
|||
(`b;20;)) |
|||
</pre> |
|||
{{works in|Kona}} |
|||
==== K6+ ==== |
|||
Takes two lists of equal length and makes a [[dictionary]] using the left argument as keys, and the right argument as the values. |
|||
Uniqueness of the keys is not enforced. |
Uniqueness of the keys is not enforced. |
||
Line 14: | Line 27: | ||
`a`b!2 |
`a`b!2 |
||
`a`b!2 2 |
`a`b!2 2 |
||
[[Category:Verbs]] |
|||
[[Category:Operator verbs]] |
|||
[[Category:Primitives]] |
Latest revision as of 06:14, 9 July 2022
Create dict
.x
x!y
x!y
The create dict primitive, a.k.a. map converts its argument(s) to a dictionary.
K3[edit]
Takes a an array of pairs and converts it to a dictionary.
.((`a;10);(`b;20)) .((`a;10;) (`b;20;))
Works in: Kona
K6+[edit]
Takes two lists of equal length and makes a dictionary using the left argument as keys, and the right argument as the values. Uniqueness of the keys is not enforced.
`a`b!3 4 [a:3;b:4] 4 5!6 7 4 5!6 7
In k7, k9, and ngn/k, if y
is an atom, it's extended to the length of x
.
`a`b!2 `a`b!2 2