Logical operations: Difference between revisions
Content added Content deleted
(added ReScript) |
(Added solution for Action!) |
||
Line 68: | Line 68: | ||
(cw "(not a) = ~x0~%" (not a))))</lang> |
(cw "(not a) = ~x0~%" (not a))))</lang> |
||
<br><br> |
<br><br> |
||
=={{header|Action!}}== |
|||
<lang Action!>BYTE FUNC Not(BYTE a) |
|||
IF a=0 THEN |
|||
RETURN (1) |
|||
FI |
|||
RETURN (0) |
|||
PROC Main() |
|||
BYTE a,b,res |
|||
FOR a=0 TO 1 |
|||
DO |
|||
FOR b=0 TO 1 |
|||
DO |
|||
res=a AND b |
|||
PrintF("%B AND %B=%B",a,b,res) |
|||
res=a OR b |
|||
PrintF("|%B OR %B=%B",a,b,res) |
|||
res=a ! b |
|||
PrintF("|%B XOR %B=%B",a,b,res) |
|||
res=Not(a) |
|||
PrintF("|NOT %B=%B%E",a,res) |
|||
OD |
|||
OD |
|||
RETURN</lang> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Logical_operations.png Screenshot from Atari 8-bit computer] |
|||
<pre> |
|||
0 AND 0=0|0 OR 0=0|0 XOR 0=0|NOT 0=1 |
|||
0 AND 1=0|0 OR 1=1|0 XOR 1=1|NOT 0=1 |
|||
1 AND 0=0|1 OR 0=1|1 XOR 0=1|NOT 1=0 |
|||
1 AND 1=1|1 OR 1=1|1 XOR 1=0|NOT 1=0 |
|||
</pre> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |