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

37 lines
717 B
Scheme
Raw Normal View History

2021-12-27 15:07:07 +00:00
#lang scheme
(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)))