A purely functional Turing machine simulator