Problem 5: Sub All (100 pts)
Write sub-all
, which takes a list s
, a list of old
words, and a list of new
words; the last two lists must be the same length. It returns a list with the elements of s, but with each word that occurs in the second argument replaced by the corresponding word of the third argument. You may use substitute
in your solution. Assume that olds
and news
have no elements in common.
(define (sub-all s olds news)
'YOUR-CODE-HERE
)
;;; Tests
; scm> (sub-all '(a (a b c) d) '(b d) '(e f))
; (a (a e c) f)