;; 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-beginner-reader.ss" "lang")((modname 23.1.1) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) ; Worked exercise 23.1.1: ; add1-each : list-of-numbers -> list-of-numbers (check-expect (add1-each empty) empty) (check-expect (add1-each (cons 3 empty)) (cons 4 empty)) (check-expect (add1-each (cons 3 (cons -12 (cons 7 empty)))) (cons 4 (cons -11 (cons 8 empty)))) (define (add1-each nums) (cond [(empty? nums) empty] [(cons? nums) ; nums (cons 3 (cons -12 (cons 7 empty))) ; (first nums) 3 ; (rest nums) (cons -12 (cons 7 empty)) ; (add1-each (rest nums)) (cons -11 (cons 8 empty)) ; right answer (cons 4 (cons -11 (cons 8 empty))) (cons (+ 1 (first nums)) (add1-each (rest nums)))] ))