one-file-projects/logic.rkt

17 lines
323 B
Racket

#lang racket
(define (_not p)
(if (equal? p 1) 0 1))
(define (_or p q)
(if (equal? p 1) 1 (if (equal? q 1) 1 0)))
(define (_and p q)
(_not (_or (_not p) (_not q))))
(define (_xor p q)
(_and (_or p q) (_not (_and p q))))
(for* ([p '(0 1)] [q '(0 1)])
(display p) (display q)
(displayln (_xor p q)))