;; 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 17.6.1) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "dir.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "dir.ss" "teachpack" "htdp"))))) ;A list-of-numbers (lon) is either ;1. empty or ;2. (cons n lon) ;where n is a number and lon is a list-of-numbers (lon). ; ;merge : lon lon -> lon ;Given lon1 and lon2, both lists-of-numbers arranged in ascending order, merge combines the two lists in ascending order and returns the list-of-numbers. (define (merge lon1 lon2) (cond [(and (empty? lon1) (empty? lon2)) empty] [(and (cons? lon1) (empty? lon2)) lon1] [(and (empty? lon1) (cons? lon2)) lon2] [(<= (first lon1) (first lon2)) (cons (first lon1) (merge (rest lon1) lon2))] [(> (first lon1) (first lon2)) (cons (first lon2) (merge lon1 (rest lon2)))])) (define list-1 '(1 3 5 7 9 21 23 25 27 29 31)) (define list-2 '(2 4 6 8 10 12 14 16))