Lecture overview -- Keyboard shortcut: 'u'  Previous page: Example of recursion: <span>number-interval</span> -- Keyboard shortcut: 'p'  Next page: Examples with recursion: <span>string-of-char-list?</span> -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Recursion and Higher-order Functions - slide 6 : 35

Examples of recursion: string-merge
The function string-merge zips two lists of strings to a single string. The lists are not necessarily of equal lengths
(define (string-merge str-list-1 str-list-2)
 (cond ((null? str-list-1) (apply string-append str-list-2))
       ((null? str-list-2) (apply string-append str-list-1))
       (else (string-append
              (car str-list-1) (car str-list-2)
              (string-merge (cdr str-list-1) (cdr str-list-2))))))
A tail recursive version of string-merge.
Go to exercise
More about string-merge