;; The first three lines of this file were inserted by DrRacket. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-abbr-reader.ss" "lang")((modname 06two-lists-lockstep) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) ;; DEMO: Working with two lists, one sealed (define (two-lists-template xs ys) (cond [(empty? xs) (cond [(empty? ys) ...] [(cons? ys) (... (first ys) ... (rest ys) ...)])] [(cons? xs) (cond [(empty? ys) (... (first xs) ... (rest xs) ...)] [(cons? ys) (... (first ys) ... (rest ys) ... (first xs) ... (rest xs) ...)])])) (define (two-lists-first-sealed-template xs ys) (cond [(empty? ys) (... xs ...)] [(cons? ys) (... (first ys) ... (rest ys) ... xs)])) ;; QUESTION: what are the natural recursions? (define (two-lists-second-sealed-template xs ys) (cond [(empty? xs) (... ys ...)] [(cons? xs) (... (first xs) ... (rest xs) ... ys)])) ;; QUESTION: what are the natural recursions? ;; my-append : list-of-numbers list-of-numbers -> list-of-numbers ;; to produce a single list containing the numbers in xs ;; followed by the numbers in ys (define (my-append xs ys) ...) (check-expect (my-append '(1 2) '(3 4 5)) '(1 2 3 4 5)) (check-expect (my-append empty '(3 4 5)) '(3 4 5)) (check-expect (my-append '(1 2) empty) '(1 2)) (check-expect (my-append empty empty) empty)