;; The first three lines of this file were inserted by DrScheme. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-intermediate-reader.ss" "lang")((modname 20.2.4) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp"))))) Exercise 20.2.4. Formulate general contracts for the following functions: sort, which consumes a list of items and a function that consumes two items (from the list) and produces a boolean; it produces a list of items. map, which consumes a function from list items to Xs and a list; it produces a list of Xs. project, which consumes a list of lists and a function from lists to Xs; it produces a list of Xs. Compare with exercise 20.2.2. Solution ;sort : (listof X) (X X -> boolean) -> (listof X) ; ;map : ((listof X) -> X) (listof Y) -> (listof X) ; ;project : (listof (listof X)) ((listof X) -> X) -> (listof X) ;sort : (listof numbers) (number number -> boolean) -> (listof numbers) ;map : (number -> number) (listof numbers) -> (listof numbers) ;project : (listof (listof symbols)) ((listof symbols) -> symbols) -> symbols