How to replace an item by another in a list in DrScheme when given paramters are two items and a list?
; replace first occurrence of b with a in list ls, q? is used for comparison (define (replace q? a b ls) (cond ((null? ls) '()) ((q? (car ls) b) (replace q? a b (cons a (cdr ls)))) (else (cons (car ls) (replace a b (cdr ls))))))