4,494
edits
(update dzaima/APL) |
m (Text replacement - "<source" to "<syntaxhighlight") |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
:''This page is about array depth, a number associated with every array. For the operator that applies a function at a given depth, see [[Depth (operator)]].'' | |||
{{Built-in|Depth|≡}} is a [[monadic]] [[primitive function]] that returns an array's depth. In the APL [[array model]], the '''depth''' of an array is the number of levels of [[Nested array model|nesting]] or [[box]]ing it exhibits. In some languages, Depth returns a negative result to indicate that not all paths through the array have the same depth. | {{Built-in|Depth|≡}} is a [[monadic]] [[primitive function]] that returns an array's depth. In the APL [[array model]], the '''depth''' of an array is the number of levels of [[Nested array model|nesting]] or [[box]]ing it exhibits. In some languages, Depth returns a negative result to indicate that not all paths through the array have the same depth. | ||
Line 12: | Line 13: | ||
An array has a ''consistent depth'' if it is a simple scalar, or if all of its elements (including the prototype, if prototypes are used to determine depth) have a consistent depth and are equal in depth. For example, the following works in all nested APLs with [[stranding]]: | An array has a ''consistent depth'' if it is a simple scalar, or if all of its elements (including the prototype, if prototypes are used to determine depth) have a consistent depth and are equal in depth. For example, the following works in all nested APLs with [[stranding]]: | ||
< | <syntaxhighlight lang=apl> | ||
≡('ab' 'cde')('fg' 'hi') | ≡('ab' 'cde')('fg' 'hi') | ||
3 | 3 | ||
</ | </syntaxhighlight> | ||
The signed depth of an array is an integer with [[Magnitude|absolute value]] equal to its positive depth. It is negative if and only if the array does not have a consistent depth. | The signed depth of an array is an integer with [[Magnitude|absolute value]] equal to its positive depth. It is negative if and only if the array does not have a consistent depth. | ||
Line 25: | Line 26: | ||
In the [[flat array model]], the depth is the number of levels of [[box]]ing in an array. More precisely, the depth of a non-boxed or [[empty]] array is 0, and a non-empty boxed array has depth equal to one plus the maximum of the depths of the arrays it contains. | In the [[flat array model]], the depth is the number of levels of [[box]]ing in an array. More precisely, the depth of a non-boxed or [[empty]] array is 0, and a non-empty boxed array has depth equal to one plus the maximum of the depths of the arrays it contains. | ||
The [[J]] language uses the token < | The [[J]] language uses the token <syntaxhighlight lang=j inline>L.</syntaxhighlight> and name "Level Of" for depth. | ||
== External links == | == External links == | ||
Line 37: | Line 38: | ||
* [https://help.dyalog.com/latest/index.htm#Language/Primitive%20Functions/Depth.htm Dyalog] | * [https://help.dyalog.com/latest/index.htm#Language/Primitive%20Functions/Depth.htm Dyalog] | ||
* [http://microapl.com/apl_help/ch_020_020_350.htm APLX] | * [http://microapl.com/apl_help/ch_020_020_350.htm APLX] | ||
* [https:// | * [https://www.jsoftware.com/help/dictionary/dlcapdot.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/lcapdot J NuVoc] (as <syntaxhighlight lang=apl inline>L.</syntaxhighlight> "Level of") | ||
* [https://mlochbaum.github.io/BQN/doc/depth.html#the-depth-function BQN] | |||
{{APL features}} | {{APL features}} | ||
{{APL built-ins}} | {{APL built-ins}}[[Category:Primitive functions]] |