Partitioned Enclose
Jump to navigation
Jump to search
⊂

Partitioned Enclose (⊂
) is a dyadic function which splits its right argument into differently sized pieces as determined by the left argument.
In the simplest case, and on a vector right argument, the corresponding element in the left argument indicates where divisions begin:
1 0 1 0 0 0 0⊂'HiEarth'
┌──┬─────┐
│Hi│Earth│
└──┴─────┘
Works in: Dyalog APL
Almost all dialects restrict the left argument to provide only this functionality. However, the left argument can be interpreted as a count of how many partitions begin with a particular position:
2 0 3 0 0 0 0⊂'HiEarth'
┌┬──┬┬┬─────┐
││Hi│││Earth│
└┴──┴┴┴─────┘
Additional trailing empty divisions are thus created by adding an additional division count corresponding to the position beyond the end of the right argument:
1 0 1 0 0 0 0 1⊂'HiEarth'
┌──┬─────┬┐
│Hi│Earth││
└──┴─────┴┘
This interpretation allows a simple definition of a splitintolengths function:
Split←{⍵ ⊂⍨ ⍸⍣¯1 +\ ¯1↓1,⍺}
3 3 4 Split 'HowAreYou?'
┌───┬───┬────┐
│How│Are│You?│
└───┴───┴────┘
Works in: Extended Dyalog APL
External links
Tutorials
Documentation
APL builtins [edit]  

Primitive functions  
Scalar  
Monadic  Conjugate ∙ Negate ∙ Signum ∙ Not ∙ Roll ∙ Type  
Dyadic  Add ∙ Subtract ∙ Equal to (Xnor) ∙ Not Equal to (Xor) ∙ Minimum ∙ Maximum ∙ Comparison functions  
NonScalar  
Structural  Shape ∙ Reshape ∙ Tally ∙ Depth ∙ Ravel ∙ Reverse ∙ Raze ∙ Mix ∙ Cut (K) ∙ Pair ∙ Replicate ∙ Partitioned Enclose  
Selection  Take ∙ Drop ∙ Unique ∙ Identity ∙ Select  
Selector  Interval Index ∙ Indices  
Computational  Match ∙ Not Match ∙ Nub Sieve ∙ Format ∙ Execute  
Primitive operators  Monadic  Each ∙ Replicate  
Dyadic  Reverse Compose  
Quad names  
Arrays  Index origin ∙ Migration level  
Functions  
Operators  
Other  Zilde ∙ High minus ∙ Function axis 