;; tlambda_DEMO.scm ;; NKU CSC 601 - Fall 2002 - Kirby ;; ------------------------------- ;; Testing ttrans, from program 2. ;; ------------------------------- (load "tlambda.scm") (define cout (lambda (expr) ; Prettyprint expr and its evaluation. (if (string? expr) (begin (display expr) (newline)) (begin (display expr) (newline) (display " => ") (display (eval expr)) (newline) (newline))))) (define myand~ (lambda (predA predB predC) ; A new functional, just for testing ttrans with an unforeseen procedure. (lambda (x) (and (predA x) (predB x) (predC x))))) ;; A bunch of tlambda definitions to test out. ;; ------------------------------------------- (for-each ttrans '( (define f1 (tlambda ((number? n)) (list 'f1: n))) (define f2 (tlambda (s) (list 'f2: s))) (define f3 (tlambda (((myand~ number? integer? positive?) n)) (list 'f3: n))) (define f4 (tlambda (a b) (list 'f4: a b))) (define f5 (tlambda ((number? n) s) (list 'f5: n s))) (define f6 (tlambda ((list-of number? s)) (list 'f6: s))) (define f7 (tlambda (a (number? x) ((myand~ number? integer? positive?) n) (list-of symbol? s)) (list 'f7: a x n s))) )) ;; Run those functions to confirm that ttrans worked. ;; -------------------------------------------------- (for-each cout '( "Should be ok:" (f1 5) "Should fail:" (f1 'woof) "Should be ok:" (f2 'woof) "Should be ok:" (f3 22) "Should fail:" (f3 -23) "Should fail:" (f3 3.4) "Should fail:" (f3 '(2 3)) "Should be ok:" (f4 'a 'b) "Should be ok:" (f5 54 '(a b)) "Should fail:" (f5 'nope '(a b)) "Should be ok:" (f6 '(3 4 5 1)) "Should fail:" (f6 256) "Should fail:" (f6 '(1 2 3 'nope)) "Should be ok:" (f7 1 3.14 4 '(a b c)) "Should fail:" (f7 1 'fog 34 '(a b)) "Should fail:" (f7 1 3.14 -34 '(a b)) "Should fail:" (f7 1 3.14 3.2 '(a b)) "Should fail:" (f7 1 3.14 'g '(a b)) "Should fail:" (f7 1 2.14 38 '(a (b d))) ))