APLX Help : Help on APL language : APL Primitives : ⊂ Partition
|
|
![]() |
|
Two-argument form See also one-argument form Enclose Partition will divide its right argument into an array of vectors according to the specification contained in its left argument. The left argument must be a scalar or a simple vector of integers that are either zero or positive, with one element for every item in the right argument. A new item is created in the result whenever the corresponding element in the left argument is greater than its predecessor. Elements in the left argument that are zero cause the corresponding items in the right argument to be omitted. If used without an axis specification, partition will select along the last axis. When used with an axis specification, selection takes place along the nominated axis. 1 1 2 2 3 3⊂1 2 3 4 5 6 1 2 3 4 5 6 (Result is 3 element vector, with each ⍴1 1 2 2 3 3⊂1 2 3 4 5 6 element a length 2 vector) 3 1 1 0 1 1 0⊂1 2 3 4 5 6 1 2 4 5 (Do not select 3rd and 6th elements) ⍴1 1 0 1 1 0⊂1 2 3 4 5 6 2 MAT←3 3⍴'CATSATMAT' MAT CAT SAT MAT ⍴MAT 3 3 1 0 1⊂MAT (Drop the second column) C T S T M T ⍴1 0 1⊂MAT 3 2 (Result is nested array) ⍴¨1 0 1⊂MAT 1 1 1 1 1 1 ≡MAT 1 ≡1 0 1⊂MAT 2 (Depth increased by 1) 1 0 1⊂MAT C T S T M T 1 0 1⊂[2]MAT (Specification of last axis is the same C T as no axis specification) S T M T 1 0 1⊂[1]MAT (Specification of first axis causes C A T selection by first axis - rows ) M A T ⍴1 0 1⊂[1]MAT 2 3 1 2 3⊂MAT (Create a new element every column) C A T S A T M A T ⍴1 2 3⊂MAT 3 3 ≡MAT (MAT is depth 1 - a simple matrix) 1 ≡1 2 3⊂MAT (The partition of MAT is depth 2 - a nested 2 matrix) 1 2 2⊂MAT (MAT is partitioned into two columns, C AT the first with one element, the second S AT with two) M AT ⍴1 2 2⊂MAT 3 2 ⍴¨1 2 2⊂MAT 1 2 1 2 1 2 |
|
APLX Help : Help on APL language : APL Primitives : ⊂ Partition
|
Copyright © 1996-2010 MicroAPL Ltd