# vim: ts=2 sw=2 et ft=ruby # Call with four binary numbers on the tape: # $ turing.rb concatenate_compare.mtm 110 1 11 01 1. right 1, goto: 2 2. cond 1, if: 'B', then: 3, else: 1 3. right 2, goto: 4 4. cond 2, if: '0', then: 7, else: 5 5. cond 2, if: '1', then: 6, else: 9 6. write 1, symbol: '1', goto: 8 7. write 1, symbol: '0', goto: 8 8. right 1, goto: 3 9. right 3, goto: 10 10. cond 3, if: 'B', then: 11, else: 9 11. right 4, goto: 12 12. cond 4, if: '0', then: 14, else: 13 13. cond 4, if: '1', then: 15, else: 17 14. write 3, symbol: '0', goto: 16 15. write 3, symbol: '1', goto: 16 16. right 3, goto: 11 17. left 3, goto: 18 18. left 1, goto: 19 19. cond 3, if: '0', then: 20, else: 22 20. cond 1, if: '0', then: 17, else: 24 21. cond 1, if: '1', then: 17, else: 24 22. cond 3, if: '1', then: 21, else: 23 23. cond 1, if: 'B', then: 25, else: 24 24. write 0, symbol: '0', goto: 26 25. write 0, symbol: '1', goto: 26 26. right 0, goto: 27 27. halt