Imp: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 20: | Line 20: | ||
|} | |} | ||
== Example == | == Example (Basic) == | ||
<pre> | <pre> | ||
Line 35: | Line 35: | ||
Print " x > 0 Imp y > 10 = " & Test2 | Print " x > 0 Imp y > 10 = " & Test2 | ||
Print " x < 0 Imp y > 10 = " & Test3 | Print " x < 0 Imp y > 10 = " & Test3 | ||
</pre> | |||
== Example (JavaScript) == | |||
<pre> | |||
// Imp Example | |||
/* Imp preforms logical and bit wise implication */ | |||
Imp = function(x,y) { | |||
if (!x || x && y) return true; | |||
return false; | |||
} | |||
var Test1, Test2, Test3, x, y; | |||
x = 3; | |||
y = 5; | |||
Test1 = Imp(x < 0,y < 10); | |||
Test2 = Imp(x > 0,y > 10); | |||
Test3 = Imp(x < 0,y > 10); | |||
NSB.Print("Logical:") | |||
NSB.Print(" x < 0 Imp y < 10 = " + Test1); | |||
NSB.Print(" x > 0 Imp y > 10 = " + Test2); | |||
NSB.Print(" x < 0 Imp y > 10 = " + Test3); | |||
</pre> | </pre> | ||
Revision as of 18:41, 27 May 2013
Result = x Imp y
Description
Imp returns the logical implication of two expressions. Logical implication returns TRUE if x implies y. Imp also does a bitwise comparison of two numeric expressions.
Table 13: Logical Implication
x | y | Implication |
---|---|---|
True/1 | True/1 | True/1 |
True/1 | False/0 | False/0 |
False/0 | True/1 | True/1 |
False/0 | False/0 | True/1 |
Example (Basic)
Rem Imp Example 'Imp preforms logical and bitwiseimplication Dim Test1, Test2, Test3, x, y x = 3 y = 5 Test1 = x < 0 Imp y < 10 Test2 = x > 0 Imp y > 10 Test3 = x < 0 Imp y > 10 Print "Logical:" Print " x < 0 Imp y < 10 = " & Test1 Print " x > 0 Imp y > 10 = " & Test2 Print " x < 0 Imp y > 10 = " & Test3
Example (JavaScript)
// Imp Example /* Imp preforms logical and bit wise implication */ Imp = function(x,y) { if (!x || x && y) return true; return false; } var Test1, Test2, Test3, x, y; x = 3; y = 5; Test1 = Imp(x < 0,y < 10); Test2 = Imp(x > 0,y > 10); Test3 = Imp(x < 0,y > 10); NSB.Print("Logical:") NSB.Print(" x < 0 Imp y < 10 = " + Test1); NSB.Print(" x > 0 Imp y > 10 = " + Test2); NSB.Print(" x < 0 Imp y > 10 = " + Test3);
Output
Logical: x < 0 IMP y < 10 = True x > 0 IMP y > 10 = False x < 0 IMP y > 10 = True