Reverse: Difference between revisions

Jump to navigation Jump to search
152 bytes added ,  13:19, 30 May 2021
Miraheze>Adám Brudzewsky
No edit summary
(→‎Documentation: BQN link)
(9 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Built-ins|Reverse|⌽|⊖}} is a [[monadic function]] which reorders [[elements]] of the argument to go in the opposite direction along a specified [[axis]]. The name Reverse is typically used for the primitive <source lang=apl inline>⌽</source>, which reverses along the last axis, while <source lang=apl inline>⊖</source>, which reverses along the first axis, is called "Reverse First", "Reverse-down", or similar. In APLs with [[function axis]], either for may use a specified axis which overrides this default choice of axis. In the [[leading axis model]], specifying an axis is discouraged in favor of using <source lang=apl inline>⊖</source> with the [[Rank operator]].
{{Built-ins|Reverse|⌽|⊖}} is a [[monadic function]] which reorders [[elements]] of the argument to go in the opposite direction along a specified [[axis]]. The name Reverse is typically used for the primitive <source lang=apl inline>⌽</source>, which reverses along the last axis, while <source lang=apl inline>⊖</source>, which reverses along the first axis, is called "Reverse First", "Reverse-down", or similar. In APLs with [[function axis]], either form may use a specified axis which overrides this default choice of axis. In the [[leading axis model]], specifying an axis is discouraged in favor of using <source lang=apl inline>⊖</source> with the [[Rank operator]].


== Examples ==
== Examples ==
Line 28: Line 28:
Reverse with a [[specified axis]] can reverse along any of the three dimensions of the array below.
Reverse with a [[specified axis]] can reverse along any of the three dimensions of the array below.
<source lang=apl>
<source lang=apl>
       ⊢a←2 3 6⍴⍳36
       ⎕←a←2 3 6⍴⍳36
  1  2  3  4  5  6
  1  2  3  4  5  6
  7  8  9 10 11 12
  7  8  9 10 11 12
Line 99: Line 99:
     ⍺ ← ¯1+≢⍴⍵                  ⍝ Assume last axis
     ⍺ ← ¯1+≢⍴⍵                  ⍝ Assume last axis
     l ← ⍺ ⌷ ⍴⍵                  ⍝ Length of reversed axis
     l ← ⍺ ⌷ ⍴⍵                  ⍝ Length of reversed axis
     (l-1+⍳l) ⌷[⍺] ⍵             ⍝ Reverse with indexing
     (⊂l-1+⍳l) ⌷[⍺] ⍵           ⍝ Reverse with indexing
}
}
</source>
</source>
Line 111: Line 111:
=== Documentation ===
=== Documentation ===


* [http://help.dyalog.com/latest/Content/Language/Primitive%20Functions/Reverse.htm Dyalog]
* [https://help.dyalog.com/latest/index.htm#Language/Primitive%20Functions/Reverse.htm Dyalog]
* [http://microapl.com/apl_help/ch_020_020_510.htm APLX]
* [http://microapl.com/apl_help/ch_020_020_510.htm APLX]
* J [https://www.jsoftware.com/help/dictionary/d231.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/bardot NuVoc] (only first-axis reverse exists)
* J [https://www.jsoftware.com/help/dictionary/d231.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/bardot NuVoc] (only first-axis reverse exists)
* [https://mlochbaum.github.io/BQN/doc/reverse.html BQN]


{{APL built-ins}}
{{APL built-ins}}[[Category:Primitive functions]][[Category:Functions with first- and last-axis forms]]

Navigation menu