string-merge-iter.scm - A tail recursive version of string-merge. | Lecture 3 - slide 22 : 42 Program 2 |
(define (string-merge-iter str-list-1 str-list-2) (merge-iter-helper str-list-1 str-list-2 "")) (define (merge-iter-helper str-list-1 str-list-2 res) (cond ((null? str-list-1) (string-append res (apply string-append str-list-2))) ((null? str-list-2) (string-append res (apply string-append str-list-1))) (else (merge-iter-helper (cdr str-list-1) (cdr str-list-2) (string-append res (car str-list-1) (car str-list-2))))))