Group: Difference between revisions

343 bytes added ,  2 years ago
add K2/K3 impl
No edit summary
(add K2/K3 impl)
Line 7:
`a`b`c`d`k!(0 1 7 8;,2;3 4 6;,5;,9)
</pre>
 
 
 
The [[keys]] from the '''group''' dictionary represent the [[distinct]] elements of the array.
Line 19 ⟶ 21:
"abrcd"
</pre>{{Works in|ngn/k}}
 
 
In K2 and K3, the group primitive returns a nested array:<pre>
="abracadabra"
(0 3 5 7 10
1 8
2 9
,4
,6)
</pre>{{Works in|Kona}}
 
In order to mimic the K6 behaviour, you can use [[distinct]]: <code>{(?x)!=x}</code> to get a dict.
 
<pre>
{(?:x)!=x}`a`a`b`c
.((`a
0 1
)
(`b
,2
)
(`c
,3
))
</pre>{{Works in|Kona}}