fork download
  1. turing(State,[Letter|Left]-Right,FinalTape):-
  2. c(State,Letter,NewState,Write,Move),
  3. move(Move,[Write|Left]-Right,NewTape),
  4. turing(NewState,NewTape,FinalTape).
  5. turing(State,Tape,Tape):-
  6. f(State).
  7.  
  8. move(none,Tape,Tape).
  9. move(left,[X|Left]-Right,NewLeft-NewRight):-
  10. (Left=[] -> NewLeft=[free] ; NewLeft=Left),
  11. (Right=[free] -> NewRight=[X] ; NewRight=[X|Right]).
  12. move(right,Left-[X|Right],NewLeft-Right):-
  13. Left=[free] -> NewLeft=[X] ; NewLeft=[X|Left].
  14. move(right,Left-[],NewLeft-[]):-
  15. Left=[free] -> NewLeft=Left ; NewLeft=[free|Left].
  16.  
Success #stdin #stdout #stderr 0.02s 6912KB
stdin
put "h"
stdout
Standard output is empty
stderr
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit