(define (cddr s)
(cdr (cdr s)))
(define (cadr s)
(car (cdr s))
)
(define (caddr s)
(car (cddr s))
)
(define (sign num)
(cond ((> num 0) 1)
((= num 0) 0)
(else -1)
)
)
(define (square x) (* x x))
(define (pow x y)
(cond ((= x 1) 1)
((= y 1) x)
((= y 0) 1)
((even? y) (square (pow x (/ y 2))))
(else (* x (square (pow x (/ (- y 1) 2)))))
)
)
CS 61A HW06
最新推荐文章于 2024-05-19 11:09:09 发布