Difference between revisions of "Commute"

From APL Wiki
Jump to navigation Jump to search
(Add a bad example...)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Built-in|Commute|⍨}} is a [[Primitive function|primitive]] [[monadic]] [[operator]] that takes a [[function]] on its left and returns a new function with swapped arguments.
+
{{Built-in|Commute|⍨}} is a [[monadic operator]] that takes a [[dyadic function]] as operand and modifies how the argument(s) of its derived functions are used. If the derived function is used monadically, the argument is also used as left argument. This usage is also known as '''Self''' or, more informally, '''Selfie'''. If the derived function is used dyadically, the arguments are swapped. This usage is also known as '''Swap'''. The [[glyph]] is also used for [[Commute]].
  
 
== Examples ==
 
== Examples ==
  
Subtract one from every item of the input array.
+
This decrements from the vector:
 
<source lang=apl>
 
<source lang=apl>
1 -⍨ 1 2 3
+
      1 -⍨ 1 2 3
 +
0 1 2
 
</source>
 
</source>
 +
{{Works in|[[Dyalog APL]], [[dzaima/APL]], [[NARS2000]]}}
 +
Double:
 +
<source lang=apl>
 +
      +⍨1 2 3
 +
2 4 6
 +
</source>
 +
{{Works in|[[Dyalog APL]], [[dzaima/APL]], [[NARS2000]]}}
  
 
== External links ==
 
== External links ==
Line 12: Line 20:
 
=== Lessons ===
 
=== Lessons ===
  
* [https://chat.stackexchange.com/transcript/52405?m=40900200#40900200 APL Cultivation]
+
* [https://chat.stackexchange.com/rooms/52405/conversation/lesson-3-some-apl-operators-----#40900200 APL Cultivation]
  
 
=== Documentation ===
 
=== Documentation ===
  
* [http://help.dyalog.com/latest/index.htm#Language/Primitive%20Operators/Commute.htm Dyalog]
+
* [https://help.dyalog.com/latest/index.htm#Language/Primitive%20Operators/Commute.htm Dyalog]
* [http://microapl.com/apl_help/ch_020_020_400.htm APLX]
 
* J [https://www.jsoftware.com/help/dictionary/d121.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/minusdot NuVoc]
 
  
{{APL built-ins}}
+
{{APL built-ins}}[[Category:Primitive operators]][[Category:Composition operators]]

Latest revision as of 04:41, 11 August 2020

Commute () is a monadic operator that takes a dyadic function as operand and modifies how the argument(s) of its derived functions are used. If the derived function is used monadically, the argument is also used as left argument. This usage is also known as Self or, more informally, Selfie. If the derived function is used dyadically, the arguments are swapped. This usage is also known as Swap. The glyph is also used for Commute.

Examples

This decrements from the vector:

      1 - 1 2 3
0 1 2

Double:

      +1 2 3
2 4 6

External links

Lessons

Documentation


APL built-ins [edit]
Primitive functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentitySelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndex
Selector Index generatorGradeIndex OfInterval IndexIndicesDeal
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Primitive operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-beamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Atop, Over) ∙ Inner ProductPowerAtUnderRankDepthVariantStencilCut (J)
Quad names
Arrays Index originMigration levelAtomic vector
Functions Case convertUnicode convert
Operators SearchReplace