; 88. Merge Sorted Array ; ; We consider that the function returns the sorted list ; instead of overwriting the nums1 list (as specified in the subject) #lang racket (define/contract (merge nums1 nums2) (-> (listof number?) (listof number?) (listof number?)) "Merge recursively two sorted lists NUMS1 and NUMS2." (cond [(null? nums1) nums2] [(null? nums2) nums1] [(< (car nums1) (car nums2)) (cons (car nums1) (merge (if (list? nums1) (cdr nums1) '()) nums2))] [else (cons (car nums2) (merge (if (list? nums2) (cdr nums2) '()) nums1))])) (for/list ([item (merge '(1 2 3) '(1 3 5))]) (println item))