Create dict: Difference between revisions

From The K Language Wiki
Content added Content deleted
(add create dict page)
 
(atom extension)
Line 1: Line 1:
{{primitive|x!y}}
{{primitive|x!y}}


The '''create dict''' primitive takes two lists of equal length and makes a [[dictionary]] using the left argument as keys, and the right argument as the values.
The '''create dict''' primitive, a.k.a. '''map''', takes two lists of equal length and makes a [[dictionary]] using the left argument as keys, and the right argument as the values.


<pre>
<pre>
Line 9: Line 9:
4 5!6 7
4 5!6 7
</pre>
</pre>

In k7, k9, and ngn/k, if <code>y</code> is an atom, it's extended to the length of <code>x</code>.
`a`b!2
`a`b!2 2

Revision as of 15:33, 15 July 2021

Create dict
x!y

The create dict primitive, a.k.a. map, takes two lists of equal length and makes a dictionary using the left argument as keys, and the right argument as the values.

  `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