High minus: Difference between revisions
(only glyph) |
m (Text replacement - "langauge" to "language") |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Built-in|High minus|¯}} or '''Negative''' is the | {{Built-in|High minus|¯}} or '''Negative''' is the [[glyph]] used in [[numeric literal]]s to indicate that a number is [[negate]]d. [[APL syntax]] dictates that it be distinct from the function [[Negate]] in order to allow all [[number]]s 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 [[argument]]s to functions, or as [[operand]]s. | ||
A high minus is also used in the TI-Basic programming language to differentiate negation from subtraction.<ref>TI-Basic Developer: [http://tibasicdev.wikidot.com/68k:negative The ‾ Command]</ref> | A high minus is also used in the TI-Basic programming language to differentiate negation from subtraction.<ref>TI-Basic Developer: [http://tibasicdev.wikidot.com/68k:negative The ‾ Command]</ref> | ||
[[J]] uses a "low minus" (an underscore; < | [[J]] uses a "low minus" (an underscore; <syntaxhighlight lang=j inline>_</syntaxhighlight>) as negative sign, while [[K]] requires at least one space between a dash (<code>-</code>) and a numeric literal to access the subtraction function as opposed to having the dash be interpreted as a negative sign. | ||
== Examples == | == Examples == | ||
Using a high minus in a [[vector]] of [[number]]s allows one number to be negated. With an ordinary minus, the expression is instead parsed as [[subtraction]], where < | Using a high minus in a [[vector]] of [[number]]s allows one number to be negated. With an ordinary minus, the expression is instead parsed as [[subtraction]], where <syntaxhighlight lang=apl inline>2 3</syntaxhighlight> is subtracted from <syntaxhighlight lang=apl inline>1</syntaxhighlight>. In both cases, APL expresses negative results using the high minus. | ||
< | <syntaxhighlight lang=apl> | ||
1 ¯2 3 | 1 ¯2 3 | ||
1 ¯2 3 | 1 ¯2 3 | ||
1 -2 3 | 1 -2 3 | ||
¯1 ¯2 | ¯1 ¯2 | ||
</ | </syntaxhighlight> | ||
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. | 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. | ||
< | <syntaxhighlight lang=apl> | ||
¯2 ↓ 3 4 5 | ¯2 ↓ 3 4 5 | ||
3 | 3 | ||
-2 ↓ 3 4 5 | -2 ↓ 3 4 5 | ||
¯5 | ¯5 | ||
</ | </syntaxhighlight> | ||
In | In languages which allow array [[operand]]s, 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]] (<syntaxhighlight lang=apl inline>⊢</syntaxhighlight>), causing it to be discarded. | ||
< | <syntaxhighlight lang=apl> | ||
+∘¯1 ⊢3 | +∘¯1 ⊢3 | ||
2 | 2 | ||
+∘-1 ⊢3 | +∘-1 ⊢3 | ||
¯3 | ¯3 | ||
</ | </syntaxhighlight> | ||
== External links == | == External links == | ||
=== Lessons === | === Lessons === | ||
Line 33: | Line 33: | ||
=== Documentation === | === Documentation === | ||
* [https://help.dyalog.com/latest/index.htm#Language/Introduction/Variables/Numbers.htm Dyalog] | * [https://help.dyalog.com/latest/index.htm#Language/Introduction/Variables/Numbers.htm Dyalog] | ||
* [https://www.jsoftware.com/help/dictionary/d030.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/under J NuVoc] (as < | * [https://www.jsoftware.com/help/dictionary/d030.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/under J NuVoc] (as <syntaxhighlight lang=j inline>_</syntaxhighlight>) | ||
== References == | == References == | ||
<references/> | <references/> | ||
{{APL glyphs}}[[Category:APL syntax]] | {{APL glyphs}}[[Category:APL syntax]][[Category:Glyphs]] |
Latest revision as of 22:10, 26 August 2024
¯
|
High minus (¯
) or Negative is the glyph used in numeric literals to indicate that a number is negated. APL syntax dictates that it be 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.
A high minus is also used in the TI-Basic programming language to differentiate negation from subtraction.[1]
J uses a "low minus" (an underscore; _
) as negative sign, while K requires at least one space between a dash (-
) and a numeric literal to access the subtraction function as opposed to having the dash be interpreted as a negative sign.
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 languages 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
External links
Lessons
Documentation
- Dyalog
- J Dictionary, J NuVoc (as
_
)
References
- ↑ TI-Basic Developer: The ‾ Command
APL glyphs [edit] | |
---|---|
Information | Glyph ∙ Typing glyphs (on Linux) ∙ Unicode ∙ Fonts ∙ Mnemonics ∙ Overstrikes ∙ Migration level |
Individual glyphs | Jot (∘ ) ∙ Right Shoe (⊃ ) ∙ Up Arrow (↑ ) ∙ Zilde (⍬ ) ∙ High minus (¯ ) ∙ Dot (. ) ∙ Del (∇ )
|