The following code replaces an element with a new element in the list
replace([H|T],A,B,[B|Result]) :- H=A, replace(T,A,B,Result).
replace([H|T],A,B,[H|Result]) :- replace(T,A,B,Result).
R = [w, b, w, c, w, d]
The following code replaces an element from a list
(define replace( lambda (x b y)
(if (null? y )
(if (eqv? (car y) x)
(cons b (replace x b (cdr y)))
(cons (car y) (replace x b (cdr y)))))))
The following code will replace a character or a word with some other character or a word. This is accomplished by the replace function in C#.
strReplace = "This is a test string.";
strReplace = Regex.Replace(strReplace, " is", " was");