English
Source / code snippets

Ternäre (Dreiwertige) Logikfunktionen (XProfan-11)

 

p.specht

in the of George Boole begründeten zweiwertigen Logik there only true and wrong. what but, if one it simply not yet decide can, but so far weiterarbeiten should, as even on reason the Datenlage already possible is? then needed one instead of two even three values: Hinzu comes the worth "M" (engl. Maybe: Perhaps, möglicherweise, kann_sein/wäre_erlaubt/weiss_nicht").


an Rosettacode-task  [...]  claims now The suitable realization this dreiwertigen Logikfunktionen, The I in nachfolgenden 3NOT(), 3AND(), 3OR(), 3XOR(), 3Equ() for Gleichheitsfunktion and 3Imp() for Implikationsfunktion (If a then b) called have. tappt im dunkeln lying now in XProfan-11 to, where I the in the Literatur verwendeten worth "M" or "?" through "2" approach have. 0 remaining furthermore "false" and 1 furthermore "true/true). worth watts on The Logiknormierung laid: one Funktionswert 0 or 2 remaining receive, eachone others worth becomes logical true = 1 normiert. The functions harren now of/ one reasonable application.
Windowtitle "Ternäre (Dreiwertige) Logikfunktionen"
Cls

proc 3val :parameters a%

    case a%=0:return 0
    case a%=2:return 2
    return 1

endproc

proc 3hardship :parameters a%

    case a%=2:return 2
    return hardship(a%)

endproc

proc 3and :parameters a%,b%

    if a%=0

        return 0

    elseif a%=2

        case b%=0:return 0
        return 2

    else

        return 3val(b%)

    endif

endproc

proc 3or :parameters a%,b%

    if a%=0

        return 3val(b%)

    elseif a%=2

        case (b%=0) or (b%=2):return 2
        return 1

    else

        return 1

    endif

endproc

proc 3Equ :parameters a%,b%

    if a%=0

        return 3hardship(b%)

    elseif a%=2

        return 2

    else

        return 3val(b%)

    endif

endproc

proc 3xor :parameters a%,b%

    if a%=0

        return 3val(b%)

    elseif a%=2

        return 2

    else

        return 3hardship(b%)

    endif

endproc

proc 3Imp :parameters a%,b%

    if a%=0:return 1

    elseif a%=2

        case b%=1:return 1
        return 2

    else

        return 3val(b%)

    endif

endproc

Test:
appendmenubar 100," 0 = false (F), 1 = true (T), ?=2: "+\
"weiss-not/möglicherweise/allows/kann_sein/Perhaps (M, Maybe)"
declare a%,b%
print
print " -------------------------------"
print "   a b not_a and or xor <=> ==>"

whileloop 0,4,2:a%=3val(&Loop)

    whileloop 0,4,2:b%=3val(&Loop)

        print " -------------------------------"
        print " |",a%,b%,"|",3hardship(a%),"|",3and(a%,b%),"|",3or(a%,b%),"|",
        print  3xor(a%,b%),"|",3Equ(a%,b%),"|",3Imp(a%,b%),"|"

    endwhile

endwhile

print " -------------------------------"
beep
waitinput
End
 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
05/29/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.498 Views

Untitledvor 0 min.
p.specht11/20/21
Uwe Lang11/20/21
Manfred Barei11/19/21
Wilfried Friebe11/17/21
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie