Partitioned Enclose: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
(Created page with "{{Built-in|Partitioned Enclose|⊂}} is a dyadic function which splits its right argument into differently sized pieces as determined by the non-negative integer left argu...")
 
No edit summary
Line 1: Line 1:
{{Built-in|Partitioned Enclose|⊂}} is a [[dyadic function]] which splits its right argument into differently sized pieces as determined by the non-negative integer left argument.
{{Built-in|Partitioned Enclose|⊂}} is a [[dyadic function]] which splits its right argument into differently sized pieces as determined by the non-negative integer<ref group=note name=max>Most dialects restrict this number to a maximum of 1.</ref> left argument.


On a vector right argument, corresponding element in the left argument indicate how many<ref group=note>Most dialects restrict the number of created divisions at any one index to a maximum of 1.</ref> '''divisions''' to begin there:
On a vector right argument, corresponding element in the left argument indicate how many<ref group=note name=max></ref> '''divisions''' to begin there:
<source lang=apl>
<source lang=apl>
       1 0 1 0 0 0 0⊂'HiEarth'
       1 0 1 0 0 0 0⊂'HiEarth'
Line 9: Line 9:
</source>
</source>
{{Works in|[[Dyalog APL]]}}
{{Works in|[[Dyalog APL]]}}
Empty divisions can be inserted by beginning more than 1 division at a particular index<ref group=note name=most>Most dialects do not support this.</ref>:
Empty divisions can be inserted by beginning more than 1 division at a particular index<ref group=note name=not>Most dialects do not support this.</ref>:
<source lang=apl>
<source lang=apl>
       2 0 3 0 0 0 0⊂'HiEarth'
       2 0 3 0 0 0 0⊂'HiEarth'
Line 16: Line 16:
└┴──┴┴┴─────┘
└┴──┴┴┴─────┘
</source>
</source>
Additional trailing empty divisions are created by adding an additional division count corresponding to the index beyond the end of the right argument<ref group=note name=most></ref>:
Additional trailing empty divisions are created by adding an additional division count corresponding to the index beyond the end of the right argument<ref group=note name=not></ref>:
<source lang=apl>
<source lang=apl>
       1 0 1 0 0 0 0 1⊂'HiEarth'
       1 0 1 0 0 0 0 1⊂'HiEarth'
Line 36: Line 36:
==Notes==
==Notes==
<references group="note"/>
<references group="note"/>
==External links==
===Tutorials===
* [https://chat.stackexchange.com/rooms/52405/conversation/lesson-7-apl-functions-#41435208 APL Cultivation]
===Documentation===
* [https://help.dyalog.com/latest/index.htm#Language/Primitive%20Functions/Partitioned%20Enclose.htm Dyalog]
{{APL built-ins}}
{{APL built-ins}}

Revision as of 11:53, 27 January 2020

Partitioned Enclose () is a dyadic function which splits its right argument into differently sized pieces as determined by the non-negative integer[note 1] left argument.

On a vector right argument, corresponding element in the left argument indicate how many[note 1] divisions to begin there:

      1 0 1 0 0 0 0⊂'HiEarth'
┌──┬─────┐
│Hi│Earth│
└──┴─────┘
Works in: Dyalog APL

Empty divisions can be inserted by beginning more than 1 division at a particular index[note 2]:

      2 0 3 0 0 0 0⊂'HiEarth'
┌┬──┬┬┬─────┐
││Hi│││Earth│
└┴──┴┴┴─────┘

Additional trailing empty divisions are created by adding an additional division count corresponding to the index beyond the end of the right argument[note 2]:

      1 0 1 0 0 0 0 1⊂'HiEarth'
┌──┬─────┬┐
│Hi│Earth││
└──┴─────┴┘

Partition allows a simple definition[note 3] of a split-into-lengths function:

Try it online!

      Split←{⍵ ⊂⍨ ⍸⍣¯1 +\ ¯1↓1,⍺}
      3 3 4 Split 'HowAreYou?'
┌───┬───┬────┐
│How│Are│You?│
└───┴───┴────┘

Notes

  1. 1.0 1.1 Most dialects restrict this number to a maximum of 1.
  2. 2.0 2.1 Most dialects do not support this.
  3. In dialects that implement the full functionality of Partitioned Enclose.

External links

Tutorials

Documentation

APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare RootRound
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentityStopSelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndexCartesian ProductSort
Selector Index generatorGradeIndex OfInterval IndexIndicesDealPrefix and suffix vectors
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axisIdentity (Null, Ident)
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)Identity (Lev, Dex)
Quad names Index originComparison toleranceMigration levelAtomic vector