Blob


1 ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 ;; about the language level of this file in a form that our tools can easily process.
3 #reader(lib "htdp-intermediate-reader.ss" "lang")((modname 21.1.2-2) (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")))))
4 map : (X -> Y) (listof X) -> (listof Y)
5 Given f and alox, map each element of type X from alox to an element in type Y according to the function f to return a (listof Y).
7 (define (map alox)
8 (fold consf alox empty))
10 consf : X (listof Y) -> (listof Y)
11 Given f, an-x, and a-loy, map an-x to an element Y according to f and then append to the beginning of a-loy.
12 (define (consf)
13 (
16 (define (fold op alox base)
17 (cond
18 [(empty? alox) base]
19 [else (op (first alox) (fold op (rest alox) base))]))