Not: Difference between revisions
Miraheze>Adám Brudzewsky m (Text replacement - "http://help.dyalog.com/latest/Content/Language/" to "http://help.dyalog.com/latest/index.htm#Language/") |
Miraheze>Marshall (Extensions) |
||
Line 24: | Line 24: | ||
The arithmetic extension <source lang=apl inline>~x</source> {{←→}} <source lang=apl inline>1-x</source> was introduced to the array langauge family by [[J]]. For arguments in the interval <math>[0,1]</math> this extension may be seen as a probabilistic interpretation of negation. | The arithmetic extension <source lang=apl inline>~x</source> {{←→}} <source lang=apl inline>1-x</source> was introduced to the array langauge family by [[J]]. For arguments in the interval <math>[0,1]</math> this extension may be seen as a probabilistic interpretation of negation. | ||
== Extensions == | |||
{| class=wikitable | |||
! Extension !! Languages | |||
|- | |||
| None || [[APL\360]], [[APL2]], [[APLX]], [[GNU APL]], [[SHARP APL]], [[Dyalog APL]], [[NARS2000]], [[ngn/apl]], [[dzaima/APL]] | |||
|- | |||
| <source lang=apl inline>1-⍵</source> || [[J]] | |||
|- | |||
| <source lang=apl inline>0≠⍵</source> || [[K]] | |||
|} | |||
== External links == | == External links == |
Revision as of 13:06, 5 November 2019
~
|
Not (~
) is a primitive monadic scalar function that returns the logical negation of a Boolean argument—that is, 0 if the argument is 1 and 1 if it is 0. In some languages, such as J, it is extended so that Not x
is equivalent to 1-x
while in others, such as K, it is extended so that Not x
is equivalent to 0=x
.
Examples
~ 0 1 1 0 1 1 0 0 1 0
Attempting to negate a non-Boolean argument usually results in a DOMAIN ERROR. In some languages it may instead subtract the argument from one.
~ 0 0.5 1 DOMAIN ERROR ~0 0.5 1 ∧
Properties
Not is the only Boolean function of a single argument which depends on that argument (it is not constant) and is not trivial (the same as Identity). Not is its own Inverse.
History
A Programming Language negates arrays using an overbar symbol like , matching a convention sometimes used in mathematics. In APL\360 the current symbol ~
was chosen, also due to its use in mathematics. Mathematical usage has arguably diverged from APL in this respect, as the negation of a variable is now more often written , using the symbol Failed to parse (syntax error): {\displaystyle ¬}
, when a prefix operator is desired.
The arithmetic extension ~x
1-x
was introduced to the array langauge family by J. For arguments in the interval this extension may be seen as a probabilistic interpretation of negation.
Extensions
Extension | Languages |
---|---|
None | APL\360, APL2, APLX, GNU APL, SHARP APL, Dyalog APL, NARS2000, ngn/apl, dzaima/APL |
1-⍵ |
J |
0≠⍵ |
K |
External links
Lessons
Documentation