This file contains hidden or 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
;; Exercise 1.3 | |
;; Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers | |
(define (square x) (* x x)) | |
(define (sum-of-squares x y) (+ (square x) (square y))) | |
(define (ss-two-largest x y z) | |
(cond ((> x y) (sum-of-squares x (max y z))) | |
(else (sum-of-squares y (max x z))))) |
This file contains hidden or 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
;; Translate into prefix form: | |
;; (5 + 4 + (2 - (3 - (6 + 4/5)))) / (3 * (6 - 2) * (2 - 7)) | |
(/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5))))) (* 3 (- 6 2) (- 2 7))) |
This file contains hidden or 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
;; What is the response printed by the interpreter for each expressoin? | |
10 | |
;; answer: 10 | |
(+ 5 3 4) | |
;; answer: 12 | |
(- 9 1) | |
;; answer: 8 | |
(/ 6 2) | |
;; answer: 3 | |
(+ (* 2 4) (- 4 6)) |
NewerOlder