Promote: Difference between revisions
(Created page with "'''Promote''' is a monadic function that adds a length-1 axis to its argument before the other axes, resulting in an array with rank one higher. It appears as a primitive in Kap (<syntaxhighlight lang=apl inline><</syntaxhighlight>, "increase rank") and Dyalog APL Vision (<syntaxhighlight lang=apl inline>∧</syntaxhighlight>), as well as J (<syntaxhighlight lang=j inline>,:</syntaxhighlight>, "'''Itemize'''"), BQN (<code>≍</code>, "...") |
No edit summary |
||
Line 1: | Line 1: | ||
'''Promote''' is a [[monadic]] [[function]] that adds a length-1 [[axis]] to its argument before the other axes, resulting in an array with [[rank]] one higher. It appears as a [[primitive]] in [[Kap]] (<syntaxhighlight lang=apl inline><</syntaxhighlight>, "increase rank") and [[Dyalog APL Vision]] (<syntaxhighlight lang=apl inline>∧</syntaxhighlight>), as well as [[J]] (<syntaxhighlight lang=j inline>,:</syntaxhighlight>, "'''Itemize'''"), [[BQN]] (<code>≍</code>, "'''Solo'''"), and [[Uiua]] (<code>¤</code>, "'''Fix'''"). In J and BQN it's paired with the related dyadic primitive [[Laminate]]. The [[K]] primitive Enlist (<code>,</code>), which creates a length-1 list containing its argument, can also be interpreted as Promote because [[depth]] and rank are equivalent in the [[list model]] of arrays. | '''Promote''' is a [[monadic]] [[function]] that adds a length-1 [[axis]] to its argument before the other axes, resulting in an array with [[rank]] one higher. It appears as a [[primitive]] in [[Kap]] (<syntaxhighlight lang=apl inline><</syntaxhighlight>, "increase rank") and [[Dyalog APL Vision]] (<syntaxhighlight lang=apl inline>∧</syntaxhighlight>), as well as [[J]] (<syntaxhighlight lang=j inline>,:</syntaxhighlight>, "'''Itemize'''"), [[BQN]] (<code>≍</code>, "'''Solo'''"), and [[Uiua]] (<code>¤</code>, "'''Fix'''"). In J and BQN it's paired with the related dyadic primitive [[Laminate]]. The [[K]] primitive Enlist (<code>,</code>), which creates a length-1 list containing its argument, can also be interpreted as Promote because [[depth]] and rank are equivalent in the [[list model]] of arrays. | ||
For an argument <syntaxhighlight lang=apl inline>A</syntaxhighlight>, promote can be implemented as <syntaxhighlight lang=apl inline>(1,⍴A) ⍴ A</syntaxhighlight> or <syntaxhighlight lang=apl inline>(⍳1) ∘.⊢ A</syntaxhighlight>. The choice to add an axis at the beginning is based on [[leading axis theory]], as this allows the axis to be placed in any other position using the [[Rank operator]]. | For an argument <syntaxhighlight lang=apl inline>A</syntaxhighlight>, promote can be implemented with [[Ravel]] with [[Function axis|axis]] as <syntaxhighlight lang=apl inline>,[⎕IO-0.5] A</syntaxhighlight>, with [[Reshape]] as <syntaxhighlight lang=apl inline>(1,⍴A) ⍴ A</syntaxhighlight>, or with [[Outer Product]] as <syntaxhighlight lang=apl inline>(⍳1) ∘.⊢ A</syntaxhighlight>. The choice to add an axis at the beginning is based on [[leading axis theory]], as this allows the axis to be placed in any other position using the [[Rank operator]]. | ||
== Documentation == | == Documentation == |
Latest revision as of 01:22, 6 February 2024
Promote is a monadic function that adds a length-1 axis to its argument before the other axes, resulting in an array with rank one higher. It appears as a primitive in Kap (<
, "increase rank") and Dyalog APL Vision (∧
), as well as J (,:
, "Itemize"), BQN (≍
, "Solo"), and Uiua (¤
, "Fix"). In J and BQN it's paired with the related dyadic primitive Laminate. The K primitive Enlist (,
), which creates a length-1 list containing its argument, can also be interpreted as Promote because depth and rank are equivalent in the list model of arrays.
For an argument A
, promote can be implemented with Ravel with axis as ,[⎕IO-0.5] A
, with Reshape as (1,⍴A) ⍴ A
, or with Outer Product as (⍳1) ∘.⊢ A
. The choice to add an axis at the beginning is based on leading axis theory, as this allows the axis to be placed in any other position using the Rank operator.
Documentation
- Kap
- J NuVoc, Dictionary
- BQN
- Uiua