Guided Practice 7.1

Design the following function

;; diff : NonEmptyListOfNumber -> 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

;; NonEmptyListOfNumber = (cons Number ListOfNumber)

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

;; Your function for the ListOfNumber must follow the template for
;; ListOfNumber, 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: Wed Oct 5 12:50:16 Eastern Daylight Time 2016