Where: Difference between revisions
Content added Content deleted
m (Lowercase title) |
("Remove lowercase again - it is in the template now") |
||
Line 1: | Line 1: | ||
{{lowercase title}} |
|||
{{primitive|&x}} |
{{primitive|&x}} |
||
Revision as of 02:03, 9 July 2022
Where
&x
where replicates each item in the domain of a list or dictionary as many times as the corresponding value (which is required to be a non-negative integer) in the range:
&1 0 1 4 2 0 2 3 3 3 3 4 4
For a boolean list it returns the positions of the truthy items:
&0 0 1 1 0 1 2 3 5
For an integer atom it generates that many zeroes:
&3 0 0 0
For a dictionary it uses the keys instead of indices:
&`a`b!2 3 `a`a`b`b`b
Deep where
A non-standard extension in ngn/k works on matrices and higher-dimensional arrays. It returns the paths to truthy atoms as the columns of a matrix:
glider:(0 1 0;1 0 0;1 1 1) &glider (0 1 2 2 2 1 0 0 1 2)