High minus

From APL Wiki
Revision as of 12:53, 15 November 2019 by Miraheze>Marshall (Created page with "{| class=vertical-navbox style="float:right; font-size:500%; margin:0 1ex;" |<code>¯</code> |} In APL syntax, the '''high minus''' (<source lang=apl inline>¯</source>) i...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
¯

In APL syntax, the high minus (¯) is a character used in numeric literals to indicate that a number is negated. It is distinct from the function Negate in order to allow all numbers to be expressed as numeric literals. This ability is particularly useful in stranding or vector notation, since a number obtained from function application is harder to use in a strand—depending on the type of stranding available, it must either be parenthesized or cannot be stranded at all. It also allows negative numbers to be used as left arguments to functions, or as operands.

Examples

Using a high minus in a vector of numbers allows one number to be negated. With an ordinary minus, the expression is instead parsed as subtraction, where 2 3 is subtracted from 1. In both cases, APL expresses negative results using the high minus.

      1 ¯2 3
1 ¯2 3
      1 -2 3
¯1 ¯2

Because the high minus is part of a number and not a separate operation, it can be used as the left argument to a function without parenthesizing it. An ordinary minus will instead apply the function to the positive number and Negate the final result.

      ¯2 ↓ 3 4 5
3
      -2 ↓ 3 4 5
¯5

In langauges which allow array operands, a negative number can be passed directly as an operand without parenthesizing it. Using an ordinary minus in the right operand will cause the minus alone to be used as the operand, while the number is not. In the expression below, it is passed as the left argument of Right (), causing it to be discarded.

      +∘¯1 ⊢3
2
      +∘-1 ⊢3
¯3