[SOLVED] CS ;eval: (+ 1 (* 2 3)) => 7

$25

File Name: CS_;eval:_(+_1_(*_2_3))___________=>_7.zip
File Size: 357.96 KB

5/5 - (1 vote)

;eval: (+ 1 (* 2 3)) => 7
; eval: +=> # ; eval: 1=> 1
; eval: (* 2 3) => 6
; eval: * => # ; eval: 2 => 2
; eval: 3 => 3
; apply: # to 2,3 => 6
; apply: + to 1,6=>7

(define (double x)(+ x x))

;eval: (double 5)=>10
; eval: double => # ; eval: 5 => 5
; apply: double to 5
;eval: (+ 5 5)
;eval: +
;eval: 5
;eval: 5
;apply: + to 5,5 => 10

;example substitution model
(double 5)
(+ 5 5)
10

;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
(f 5)
(sos (+ 5 1)(* 5 2))
(sos 6 10)
(+ (square 6)(square 10))
(+ (* 6 6)(* 10 10))
(+ 36 100)
136

;special form
(define newVar (+ 1 2))

Reviews

There are no reviews yet.

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

Shopping Cart
[SOLVED] CS ;eval: (+ 1 (* 2 3)) => 7
$25