Array model: Difference between revisions

Jump to navigation Jump to search
59 bytes added ,  10:48, 18 October 2019
Miraheze>Marshall
Miraheze>Marshall
Line 71: Line 71:
{{Main|Depth}}
{{Main|Depth}}


The depth is the level of nesting. For example an array of simple (i.e. non-nested) scalars has depth 1, an array containing only depth 1 arrays has depth 2 and a simple scalar (e.g a number or character) has depth 0. However, for some arrays it's not so easy. An array may contain both vectors and scalars. In cases like this, some APLs report the depth is as negative.
The depth is the level of nesting or boxing in an array. It is defined differently in nested and flat APLs.


You can find the depth of an array with the monadic [[primitive function]] <code>≡</code>. For example:
In nested APLs, a simple non-scalar array has depth 1, an array containing only depth 1 arrays has depth 2, and a simple scalar (e.g a number or character) has depth 0.


Most APLs provide a Depth function <code>≡</code> to find an array's depth. For example:
<source lang=apl>
<source lang=apl>
       ≡('ab' 'cde')('fg' 'hi')
       ≡('ab' 'cde')('fg' 'hi')
3
3
</source>
</source>
APLs vary in their definition of depth: for example some may return the depth with a sign to indicate that some level of the array mixes elements of different depths.


=== Rank ===
=== Rank ===
Anonymous user

Navigation menu