Bind: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
No edit summary
m (Text replacement - "<source" to "<syntaxhighlight")
Line 1: Line 1:
{{Built-in|Bind|∘}} is a [[primitive operator]]. It shares the glyph [[Jot]] (<source lang=apl inline>∘</source>) with [[Beside]]; in many dialects the two operators share the name [[Compose]]. <source lang=apl inline>∘</source> means Bind if any [[operand]] is an [[array]]. Its [[derived function]]s can only be called monadically.
{{Built-in|Bind|∘}} is a [[primitive operator]]. It shares the glyph [[Jot]] (<syntaxhighlight lang=apl inline>∘</source>) with [[Beside]]; in many dialects the two operators share the name [[Compose]]. <syntaxhighlight lang=apl inline>∘</source> means Bind if any [[operand]] is an [[array]]. Its [[derived function]]s can only be called monadically.


Called with an array left operand <source lang=apl inline>A</source> and function right operand <source lang=apl inline>g</source>, <source lang=apl inline>(A∘g) X</source> is equivalent to <source lang=apl inline>A g X</source>.
Called with an array left operand <syntaxhighlight lang=apl inline>A</source> and function right operand <syntaxhighlight lang=apl inline>g</source>, <syntaxhighlight lang=apl inline>(A∘g) X</source> is equivalent to <syntaxhighlight lang=apl inline>A g X</source>.


Called with a function left operand <source lang=apl inline>f</source> and array right operand <source lang=apl inline>B</source>, <source lang=apl inline>(f∘B) X</source> is equivalent to <source lang=apl inline>X f B</source>.
Called with a function left operand <syntaxhighlight lang=apl inline>f</source> and array right operand <syntaxhighlight lang=apl inline>B</source>, <syntaxhighlight lang=apl inline>(f∘B) X</source> is equivalent to <syntaxhighlight lang=apl inline>X f B</source>.


== Common usage ==
== Common usage ==
Bind is used to create a derived function with a single constant argument, particularly in [[tacit programming]]:
Bind is used to create a derived function with a single constant argument, particularly in [[tacit programming]]:
[https://tio.run/##SyzI0U2pTMzJT///3zMv@VHbBO1HHTMMuR71TQWygSIKhgpGCsb//wMA Try it online!]<source lang=apl>
[https://tio.run/##SyzI0U2pTMzJT///3zMv@VHbBO1HHTMMuR71TQWygSIKhgpGCsb//wMA Try it online!]<syntaxhighlight lang=apl>
       Inc←+∘1
       Inc←+∘1
       Inc 1 2 3
       Inc 1 2 3

Revision as of 21:31, 10 September 2022

Bind () is a primitive operator. It shares the glyph Jot (<syntaxhighlight lang=apl inline>∘</source>) with Beside; in many dialects the two operators share the name Compose. <syntaxhighlight lang=apl inline>∘</source> means Bind if any operand is an array. Its derived functions can only be called monadically.

Called with an array left operand <syntaxhighlight lang=apl inline>A</source> and function right operand <syntaxhighlight lang=apl inline>g</source>, <syntaxhighlight lang=apl inline>(A∘g) X</source> is equivalent to <syntaxhighlight lang=apl inline>A g X</source>.

Called with a function left operand <syntaxhighlight lang=apl inline>f</source> and array right operand <syntaxhighlight lang=apl inline>B</source>, <syntaxhighlight lang=apl inline>(f∘B) X</source> is equivalent to <syntaxhighlight lang=apl inline>X f B</source>.

Common usage

Bind is used to create a derived function with a single constant argument, particularly in tacit programming: Try it online!<syntaxhighlight lang=apl>

     Inc←+∘1
     Inc 1 2 3

2 3 4 </source>

External links

Lessons

Documentation


APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
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 axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)
Quad names Index originComparison toleranceMigration levelAtomic vector