The problem’s specification is not clear.
Is it:
homework(ListOfAtoms, TargetAtom, ReplacementAtom, ResultList)
where the ResultList is a copy of the ListOfAtoms with every instance of the TargetAtom replaced by ReplacementAtom? This would be a suitable problem for Prolog beginners.
Or is every *part* of of an atom which matches TargetAtom replaced (e.g., this_atom matches is_a)? If so, there are then further specification issues involving multiple matching parts and rescanning after a change.
Tip: Precise specifications are really really important, really. Note that every syntactically correct program, no matter how awful, is the fully correct implementation of *some* specification. (Reread that a few times until you understand it and believe it.)
--
---------------------------
| BBB b \ Barbara at LivingHistory stop co stop uk
| B B aa rrr b |
| BBB a a r bbb | ,008015L080180,022036,029037
| B B a a r b b | ,047045,L014114L4.
| BBB aa a r bbb |
-----------------------------