;; ===================================================================================== ;; _____ __ __ ____ _ __ __ ____ ___ ;; / ____/ |/ / __ \/ / / / < / __ < / Spring 2019 Section 54 ;; / / / /|_/ / /_/ / / / /_____/ / / / / / ;; / /___/ / / / ____/ /_/ /_____/ / /_/ / / Assignment 1 ;; \____/_/ /_/_/ \____/ /_/\____/_/ ;; ;; S .d8888. .d88b. db db db d888888b d888888b .d88b. d8b db .d8888. ;; A 88' YP .8P Y8. 88 88 88 `~~88~~' `88' .8P Y8. 888o 88 88' YP ;; M `8bo. 88 88 88 88 88 88 88 88 88 88V8o 88 `8bo. ;; P `Y8b. 88 88 88 88 88 88 88 88 88 88 V8o88 `Y8b. ;; L db 8D `8b d8' 88booo. 88b d88 88 .88. `8b d8' 88 V888 db 8D ;; E `8888Y' `Y88P' Y88888P ~Y8888P' YP Y888888P `Y88P' VP V8P `8888Y' ;; ;; ===================================================================================== (load "asmt-helper.txt") (header "Professor Ellis" "SOLUTIONS FOR ASSIGNMENT ONE") (problem "1") (define sq (lambda (x) (* x x))) (tester '(sq 3)) (tester '(sq -5)) (tester '(sq 47)) (newline) (problem "2") (define cube (lambda (x) (* x x x))) (tester '(cube 3)) (tester '(cube -2)) (tester '(cube 1701)) (newline) (problem "3") (define hello (lambda (name) (printf "Hello ~A, nice to meet you!\n" name))) (tester '(hello 42)) (tester '(hello "world")) (tester '(hello "Captain Kirk")) (newline) (problem "4") (define val (lambda (x) (printf "~A squared is ~A and ~A cubed is ~A.\n" x (sq x) x (cube x)))) (tester '(val 4)) (tester '(val -2.48)) (tester '(val 5)) (newline) (problem "5") (define sphere (lambda (r) (printf "Sphere with radius ~A has surface area ~A and volume ~A.\n" r (* 4 3.1415926 (sq r)) (* 1.33333 3.1415926 (cube r))))) (tester '(sphere 1)) (tester '(sphere 2)) (tester '(sphere 9.5)) (newline)