Depth (operator): Difference between revisions

Jump to navigation Jump to search
1 byte added ,  20:05, 14 September 2022
m
(sub-element → sub-array as per https://help.dyalog.com/latest/Content/Language/Introduction/Variables/Arrays.htm)
Line 6: Line 6:
The Depth operator is a generalisation of the [[Each]] operator (as <code>¨</code>). While Each switches application from being directly on array arguments, to be on their elements, Depth allows exact specification of the depth level of each argument that the function is applied to.
The Depth operator is a generalisation of the [[Each]] operator (as <code>¨</code>). While Each switches application from being directly on array arguments, to be on their elements, Depth allows exact specification of the depth level of each argument that the function is applied to.


Depth is closely related to [[Rank (operator)|Rank]] (<syntaxhighlight lang=apl inline>⍤</syntaxhighlight>), but while Rank specifies the [[rank]] of the final arguments of theleft operand function, Depth specifies the [[depth]] of the final arguments of the left operand function.
Depth is closely related to [[Rank (operator)|Rank]] (<syntaxhighlight lang=apl inline>⍤</syntaxhighlight>), but while Rank specifies the [[rank]] of the final arguments of the left operand function, Depth specifies the [[depth]] of the final arguments of the left operand function.


For all arguments, when applied with a non-negative right depth specification (the right operand), and also with negative depth specification even when the arguments are ragged (of non-uniform depth), <syntaxhighlight lang=apl inline>f⍥p⊢Y</syntaxhighlight> is equivalent to <syntaxhighlight lang=apl inline>f¨¨</syntaxhighlight>…<syntaxhighlight lang=apl inline>¨¨Y</syntaxhighlight> and <syntaxhighlight lang=apl inline>X f⍥p⊢Y</syntaxhighlight> is equivalent to <syntaxhighlight lang=apl inline>(⊂⊂</syntaxhighlight>…<syntaxhighlight lang=apl inline>⊂⊂X)f¨¨</syntaxhighlight>…<syntaxhighlight lang=apl inline>¨¨⊂⊂</syntaxhighlight>…<syntaxhighlight lang=apl inline>⊂⊂Y</syntaxhighlight> where "<code>xx</code>…<code>xx</code>" indicates some number of repetitions of the function or operator <code>x</code>.
For all arguments, when applied with a non-negative right depth specification (the right operand), and also with negative depth specification even when the arguments are ragged (of non-uniform depth), <syntaxhighlight lang=apl inline>f⍥p⊢Y</syntaxhighlight> is equivalent to <syntaxhighlight lang=apl inline>f¨¨</syntaxhighlight>…<syntaxhighlight lang=apl inline>¨¨Y</syntaxhighlight> and <syntaxhighlight lang=apl inline>X f⍥p⊢Y</syntaxhighlight> is equivalent to <syntaxhighlight lang=apl inline>(⊂⊂</syntaxhighlight>…<syntaxhighlight lang=apl inline>⊂⊂X)f¨¨</syntaxhighlight>…<syntaxhighlight lang=apl inline>¨¨⊂⊂</syntaxhighlight>…<syntaxhighlight lang=apl inline>⊂⊂Y</syntaxhighlight> where "<code>xx</code>…<code>xx</code>" indicates some number of repetitions of the function or operator <code>x</code>.

Navigation menu