Scheme coding assignment

Viewed 26

I got stuck with this assignment in Scheme. To be honest, I have no idea about it. Could anyone give me ideas for this coding assignment?

Create a function that given a "list", returns a copy with all instances of "old" substituted by "new", including in nested lists.

HINT: You will need to use recursion, car and cdr. You may also want to use the following predicates:

  • pair? ---Identifies if something is a pair. Recall that all lists are built from pairs.
  • equal? ---Does standard equality testing. Note that = only works for numbers, unlike equal?.
  • null? ---Tests if something is null. Recall that lists are nil/null terminated.

The code starts like this:

(define (subst new old list)
   ..... )
0 Answers
Related