handball/src/test/pass/lambda-calc.scm

28 lines
697 B
Scheme
Raw Normal View History

(define (displayln x) (display x) (newline))
(define (printbool x) (displayln (bool->int x)))
(define (true x y) x)
(define (false x y) y)
(define (and x y) (x y x))
(define (or x y) (x x y))
(define (not x) (x false true))
(define (bool->int x)
(if
(equal? x true) 1
(if (equal? x false) 0 (- 1))))
(printbool true)
(printbool false)
(printbool bool->int)
(printbool (not true))
(printbool (not false))
(printbool (and true true))
(printbool (and true false))
(printbool (and false true))
(printbool (and false false))
(printbool (or true true))
(printbool (or true false))
(printbool (or false true))
(printbool (or false false))
(printbool (and (or true false) (or false true)))