create dict

From The K Language Wiki
Revision as of 15:36, 15 July 2021 by Ngn (talk | contribs) (uniqueness of keys)
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. 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