; File: substfirst.scm ; Title: Substitution of OLD with NEW in a list ; Ex: (subst0 'd 'c '(a b c d c (c))) ; (a b d d c (c)) ;;Recursive method for the substitution of the first occurrence only ; (define subst0 (lambda (n v L) ; n=new v=old L=list ( cond ( (null? L) () ) ( (equal? (car L) v) (cons n (cdr L)) ) ( #t (cons (car L) (subst0 n v (cdr L)) )) )) )