That text describes the following (Python) pseudocode: subs = a list of string pairs As = a list of integers Bs = a list of integers def f(state, pc): if pc == N: return (state, pc) if state.find(subs[pc][0]) != -1: return (state.replace(subs[pc][0],subs[pc][1],1), Bs[pc]) else: return (state,As[pc]) The function f is presumably going to be applied repeatedly. The last three bullet points is all you really need once you understand the notations. All that comes before is a bit analogous to explaining how Python works before giving the Python code.