[SOLVED] CS ;some functions

$25

File Name: CS_;some_functions.zip
File Size: 169.56 KB

5/5 - (1 vote)

;some functions
(define (square x)(* x x))
(define (sos x y)(+ (square x)(square y)))
(define (f a)(sos (+ a 1)(* a 2)))

;substitution model (applicative order)
;(f 5)
;(sos (+ 5 1)(* 5 2))
;(sos 6 10)
;(+ (square 6)(square 10))
;(+ (* 6 6)(* 10 10))
;(+ 36 100)
;136

;substitution model (normal order)
;(f 5)
;(sos (+ 5 1)(* 5 2))
;(+ (square (+ 5 1))(square (* 5 2))
;(+ (* (+ 5 1)(+ 5 1)) (square (* 5 2)))
;(+ (* 6 6) (square (* 5 2)))
;(+ 36 (square (* 5 2)))
;(+ 36 (* (* 5 2)(* 5 2)))
;(+ 36 (* 10 10))
;(+ 36 100)
;136

;(f 5)
;(sos (+ 5 1)(* 5 2))
;(+ (square (+ 5 1))(square (* 5 2)))
;(+ (* (+ 5 1)(+ 5 1)) (* (* 5 2)(* 5 2)))
;(+ (* 6 6)(* 10 10))
;(+ 36 100)
;136

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS ;some functions
$25