(define (max x y)
(if (>= x y) x y))
(define (example x y z)
((if (> x 5) + *)
(if (< y 10) y z) (if (and (< x y)(< z y)) (- y x) (* x z))))(example 10 2 3);substitution model;(example 10 2 3);((if (> 10 5) + *)(if (< 2 10) 2 3)(if (and (< 10 2)(< 3 2))(- 2 10)(* 10 3)));((if #t + *)(if (< 2 10) 2 3)(if (and (< 10 2)(< 3 2))(- 2 10)(* 10 3)));(+ (if (< 2 10) 2 3)(if (and (< 10 2)(< 3 2))(- 2 10)(* 10 3)));(+ (if #t 2 3)(if (and (< 10 2)(< 3 2))(- 2 10)(* 10 3)));(+ 2 (if (and (< 10 2)(< 3 2))(- 2 10)(* 10 3)));(+ 2 (if (and #f (< 3 2))(- 2 10)(* 10 3)));(+ 2 (if #f (- 2 10)(* 10 3)));(+ 2 (* 10 3));(+ 2 30);32;(example 10 2 3);((if (> 10 5) + *)(if (< 2 10) 2 3)(if (and (< 10 2)(< 3 2))(- 2 10)(* 10 3)));(+ (if (< 2 10) 2 3)(if (and (< 10 2)(< 3 2))(- 2 10)(* 10 3)))(define (signum x)(if (> x 0) 1
(if (< x 0) -1 0)))(define (signum2 x)(cond ((> x 0) 1)
((< x 0) -1)((= x 0) 0)));substitution model;(signum2 -3);(cond ((> -3 0) 1)((< -3 0) -1)((= -3 0) 0));(cond (#f 1)((< -3 0) -1)((= -3 0) 0));(cond (#f 1)(#t -1)((= -3 0) 0));-1;(signum2 -3);(cond ((> -3 0) 1)((< -3 0) -1)((= -3 0) 0));-1(define (signum3 x)(cond ((> x 0) (display positive) 1)
((< x 0) (display “negative”) -1)(else (display “zero”) 0)))
Reviews
There are no reviews yet.