;; 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-lambda-reader.ss" "lang")((modname map) (read-case-sensitive #t) (teachpacks ((lib "testing.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "testing.ss" "teachpack" "htdp"))))) ;; map is a function that allows you to apply a function to ;; every element of a list and create a new list out of ;; the results. ;; number -> number ;; computes square of x (define (square x) (* x x)) (map square (list 1 2 5 8 0 -3 -4)) ;; expected value (list 1 4 25 64 0 9 16) (map length (list (list 1 2 3) (list 'a 'b 'c 'd) empty)) ;; expected value (list 3 4 0) (map even? (list 1 2 5 8 0 -3 -4)) ;; what do you expect to be returned? ;; use the test examples above to write your own definition of map, ;; call it map1 ;; Don't forget the contract!