Solution

ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2015/functional-programming-design-and-analysis-of-algorithms/3/b/solution

Apply one replacement to each original character and concatenate the results:
step :: [Rule] -> State -> State
step rules = concatMap (applyRule rules)
The concatMap operation combines a map function and list concatenation. Replacements occur in original-character order, so a character produced by a replacement is not processed again during the same step. This is parallel string rewriting. In particular step rules "" = "", with no rule lookup required for the empty state.

New to topics? Read the docs here!