How to replace an item by another in a list in DrScheme when given paramters are two items and a list?
This replaces all the occurrences of fsym in the list lst to the symbol tsym in DrRacket
(define (subst fsym tsym lst)
(cond
[(null? lst) lst]
[eq? (first lst) fsym)(cons tsym (subst fsym tsym (rest lst)))]
[else (cons (first lst)(subst fsym tsym (rest lst)))]))
(subst 'a 'b '(f g a h a))
;the results will be as follows.
'(f g b h b)