Function axis: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
Miraheze>Adám Brudzewsky
m (Text replacement - "<code>" to "<source lang=apl inline>")
Miraheze>Adám Brudzewsky
m (Text replacement - "</code>" to "</source>")
Line 1: Line 1:
In many APLs the behavior of a function may be modified using bracket notation, for example <source lang=apl inline>⌽[2]</code> to [[Rotate]] along the second [[axis]]. Axis specification was a feature of [[Iverson notation]] and was ubiquitous in early APLs; many newer APLs which adhere to [[leading axis theory]] reject the use of axis specification in favor of the [[Rank operator]] because it is a fully general operator while the behavior of functions with axis must be defined for each function separately.
In many APLs the behavior of a function may be modified using bracket notation, for example <source lang=apl inline>⌽[2]</source> to [[Rotate]] along the second [[axis]]. Axis specification was a feature of [[Iverson notation]] and was ubiquitous in early APLs; many newer APLs which adhere to [[leading axis theory]] reject the use of axis specification in favor of the [[Rank operator]] because it is a fully general operator while the behavior of functions with axis must be defined for each function separately.


== Functions with Axis ==
== Functions with Axis ==

Revision as of 09:07, 29 October 2019

In many APLs the behavior of a function may be modified using bracket notation, for example ⌽[2] to Rotate along the second axis. Axis specification was a feature of Iverson notation and was ubiquitous in early APLs; many newer APLs which adhere to leading axis theory reject the use of axis specification in favor of the Rank operator because it is a fully general operator while the behavior of functions with axis must be defined for each function separately.

Functions with Axis

The following monads may allow an axis:

  • Mix accepts a list of axes to specify where the axes of argument elements will be placed in the result.
  • Ravel accepts a list of axes which are combined, or a single fractional number to add a length-1 axis.
  • Enclose accepts a list of axes. Each subarray along these axes is enclosed.
  • Split accepts a single axis, and encloses each vector along that axis.
  • Reverse reverses along the specified axis.

The following dyads may allow one:

  • Scalar dyadics accept a list of axes to override conformability rules: it specifies , for each axis in the lower-rank (or left, in case of a tie) argument, which axis in the other argument it is paired with.
  • Catenate combines along the selected axis, adding a new axis if a non-integer axis is given.
  • Rotate rotates the right argument along the selected axis.
  • Replicate and Expand work on the specified right argument axis.
  • Take and Drop modify the selected right argument axes.
  • Squish takes axes to specify which axis of the right argument corresponds to each left argument element.
  • Partition and Partitioned Enclose have complicated and different behavior.

Additionally, reduction and scan operators may admit axis specification. In Dyalog APL, a slash with axis retains its function-operator overloading: it can be applied as an operator or as a dyadic function (Replicate or Expand).