Write definitions for consp-or-variable-p, unify-first!, and unify – rest !, and change the compiler to generate code like that outlined previously. You might want to look at the function compile – rule in section 9.6, starting on page 300. This function compiled a call to pat -match into individual tests; now we want to do the same thing to unify ! . Run some benchmarks to compare the altered compiler to the original version.