Shape: Difference between revisions

From The K Language Wiki
Content added Content deleted
("Add category")
("Add all appropriate categories to each verb")
Line 14: Line 14:


[[Category:Operator verbs]]
[[Category:Operator verbs]]
[[Category:Verbs]]
[[Category:Primitives]]

Revision as of 03:16, 9 July 2022

Shape
^x
Supported in k3, kona
Not supported ink4, oK, ngn/k, k9

shape is a primitive that returns the list of lengths along all axes of a uniform array. For ragged arrays it returns only as many items as there are levels of uniformity.

 ^(0 1 2;"ab",`c)
2 3
 ^(0 1 2;"abcd")
,2

For rectangular arrays, it can be implemented as [1]:

 d:-1_#:'*:\
 
 d[+4 3#1]
3 4