#|
A hand-evaluation consists of a series of
expressions, all of whom have the same value.
They are the expressions that you see when using DrScheme's Stepper.
For example:
|#
;; square: number --> number
;; Given a, return a^2.
;;
(define (square a) (* a a))
;; hypotenuse: number, number --> number
;; Given the length of two legs a,b of a triangle,
;; return the length of the hypotenuse.
;; a,b are expected to be non-negative.
;;
(define (hypotenuse a b)
(sqrt (+ (square a) (square b)))
;;;;;;;;;;;;;;;; Okay, a sample hand-evalation: ;;;;;;;;;;;;;;;;;;
(hypotenuse 12 5)
= (sqrt (+ (square 12) (square 5))
= (sqrt (+ (* 12 12) (square 5))
= (sqrt (+ 144 (square 5))
= (sqrt (+ 144 (* 5 5))
= (sqrt )
= (sqrt 169)
= 13
#|
You can double-check this in drscheme by typing this into the
definition window without the =; presseing Execute
you'll see 13, repeated eight times.
However, in what you turn in, include the equal-signs,
since you really do want to link these eight statements together,
asserting that they really are equal.
Do not use other symbols instead of "=". In particular,
many people want to use arrows.
You never wrote "2 + 3 --> 5" in junior high;
2+3 doesn't transform into 5; it *is* 5.
|#
;;; Alternately, if you want to be able to double-check this
;;; in drscheme, you can call drscheme's function "=", applied
;;; to eight things:
;;;
(= (hypotenuse 12 5)
(sqrt (+ (square 12) (square 5))
(sqrt (+ (* 12 12) (square 5))
(sqrt (+ 144 (square 5))
(sqrt (+ 144 (* 5 5))
(sqrt )
(sqrt 169)
13)
;;;
;;; We'll see soon, that = is (just another) function that takes in numbers
;;; and returns true or false, depending on whether the input(s) are equal.
;;; So if you did each step correctly, what should this evaluate one
;;; expression evaluate to?