This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (make-rat n d) | |
(if (> d 0) | |
(cons n d) (cons (* -1 n) (* -1 d)) | |
)) | |
(define (numer x) (car x)) | |
(define (denom x) (cdr x)) | |
(define (mul-rat x y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (make-segment s e) (cons s e)) | |
(define (start-segment x) (car x)) | |
(define (end-segment x) (cdr x)) | |
(define (midpoint-segment x) (/ (+ (start-segment x) (end-segment x)) 2)) | |
(define (print-point p) | |
(newline) | |
(display "(") | |
(display (start-segment p)) | |
(display ",") | |
(display (end-segment p)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(define (make-point s e) (cons s e)) | |
;(define (point-x z) (car z)) | |
;(define (point-y z) (cdr z)) | |
; | |
;(define (make-pryam point1 point3) (cons point1 point3)) | |
;(define (get-point1 x) ( car x)) | |
;(define (get-point3 x) ( cdr x)) | |
;(define (get-length x) (abs (- (point-x (get-point1 x)) (point-x (get-point3 x))))) | |
;(define (get-heigth x) (abs (- (point-y (get-point1 x)) (point-y (get-point3 x))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (cons x y) | |
(lambda (m) (m x y))) | |
(define (car z) | |
(z (lambda (p q) p))) | |
(define (cdr z) | |
(z (lambda (p q) q))) | |
(car (cons 1 2)) | |
(car (cons 3 5)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (cons x y) | |
(* (expt 2 x) (expt 3 y))) | |
(define (factor base value) | |
(define (factor-iter value counter) | |
(if (= (remainder value base) 0) | |
(factor-iter (/ value base) (+ counter 1)) | |
counter)) | |
(factor-iter value 0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define zero (lambda (f) (lambda (x) x))) | |
(define one | |
(lambda (f) (lambda (x) (f x)))) | |
(define two | |
(lambda (f) (lambda (x) (f (f x))))) | |
(define (add-1 n) | |
(lambda (f) (lambda (x) (f ((n f) x))))) | |
(define zero?? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (make-interval a b) (cons a b)) | |
(define (upper-bound x) (car x)) | |
(define (lower-bound x) (cdr x)) | |
(upper-bound (make-interval 4 5)) | |
(lower-bound (make-interval 4 5)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (make-interval a b) (cons a b)) | |
(define (upper-bound x) (car x)) | |
(define (lower-bound x) (cdr x)) | |
(define (sub-interval a b) | |
(make-interval | |
(- (upper-bound a) (lower-bound b)) | |
(- (lower-bound a) (upper-bound b)) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (make-interval a b) (cons a b)) | |
(define (upper-bound x) (car x)) | |
(define (lower-bound x) (cdr x)) | |
(define (width x) (- (cdr x) (car x))) | |
(define (sub-interval a b) | |
(make-interval | |
(- (upper-bound a) (lower-bound b)) | |
(- (lower-bound a) (upper-bound b)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (make-interval a b) (cons a b)) | |
(define (upper-bound x) (car x)) | |
(define (lower-bound x) (cdr x)) | |
(define (width x) (- (cdr x) (car x))) | |
(define (mul-interval x y) | |
(let ((p1 (* (lower-bound x) (lower-bound | |
y))) | |
(p2 (* (lower-bound x) (upper-bound |
OlderNewer