How to resolve the algorithm Ternary logic step by step in the Run BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Ternary logic step by step in the Run BASIC programming language

Table of Contents

Problem Statement

In logic, a three-valued logic (also trivalent, ternary, or trinary logic, sometimes abbreviated 3VL) is any of several many-valued logic systems in which there are three truth values indicating true, false and some indeterminate third value.
This is contrasted with the more commonly known bivalent logics (such as classical sentential or boolean logic) which provide only for true and false. Conceptual form and basic ideas were initially created by Łukasiewicz, Lewis and Sulski. These were then re-formulated by Grigore Moisil in an axiomatic algebraic form, and also extended to n-valued logics in 1945.

Note:   Setun   (Сетунь) was a   balanced ternary   computer developed in 1958 at   Moscow State University.   The device was built under the lead of   Sergei Sobolev   and   Nikolay Brusentsov.   It was the only modern   ternary computer,   using three-valued ternary logic

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Ternary logic step by step in the Run BASIC programming language

Source code in the run programming language

testFalse	= 0  ' F
testDoNotKnow	= 1  ' ?
testTrue	= 2  ' T
 
print "Short and long names for ternary logic values"
for i = testFalse to testTrue
    print shortName3$(i);" ";longName3$(i)
next i
print
 
print "Single parameter functions"
print "x";" ";"=x";"  ";"not(x)"
for i = testFalse to testTrue
    print shortName3$(i);"  ";shortName3$(i);"    ";shortName3$(not3(i))
next
print
 
print "Double  parameter fuctions"
html ""for a	= testFalse to testTrue    for b	= testFalse to testTrue      html ""    nextnexthtml "
xyx AND yx OR yx EQ yx XOR y
" html shortName3$(a); "";shortName3$(b); "" html shortName3$(and3(a,b));"";shortName3$(or3(a,b)); "" html shortName3$(eq3(a,b)); "";shortName3$(xor3(a,b));"
"
function and3(a,b) and3 = min(a,b) end function function or3(a,b) or3 = max(a,b) end function function eq3(a,b) eq3 = testFalse if a = tDontKnow or b = tDontKnow then eq3 = tDontKnow if a = b then eq3 = testTrue end function function xor3(a,b) xor3 = not3(eq3(a,b)) end function function not3(b) not3 = 2-b end function '------------------------------------------------ function shortName3$(i) shortName3$ = word$("F ? T", i+1) end function function longName3$(i) longName3$ = word$("False,Don't know,True", i+1, ",") end function

You may also check:How to resolve the algorithm Sum of squares step by step in the Fantom programming language
You may also check:How to resolve the algorithm Loops/Do-while step by step in the Verbexx programming language
You may also check:How to resolve the algorithm Sorting algorithms/Counting sort step by step in the Java programming language
You may also check:How to resolve the algorithm Munchausen numbers step by step in the RPL programming language
You may also check:How to resolve the algorithm Queue/Definition step by step in the ATS programming language