Guided Practice 7.1

Design the following function

;; diff : NonEmptyNumberList -> Number
;; GIVEN: a nonempty list of numbers
;; RETURNS: the result of subtracting the numbers, from left to right.
;; EXAMPLE:
;; (diff (list 10 5 3)) = 2

;; Hints:  

;; Use the data definition

;; NonEmptyNumberList = (cons Number NumberList)

;; You will need one function for the whole list, and one for the
;; NumberList.

;; Your function for the NumberList must follow the template for
;; NumberList, but you will need a context argument.  Think carefully
;; about what the context argument means.

The function definition for this is pretty easy. The important part is getting the GIVEN/WHERE/RETURNS right.

[Solution]


Last modified: Mon Oct 2 13:22:15 Eastern Daylight Time 2017