Commit 19fcba12 authored by Brian Guadalupe's avatar Brian Guadalupe

Properly implemented tape-contents function

parent e2a52251
......@@ -103,11 +103,13 @@
(tape-list->string (cdr (tape-after tape))))))
(define (tape-contents tm)
(let ([tape (tm-config-tape tm)])
(format "~a~a~a"
(tape-list->string (reverse (tape-before tape)))
(tape-head tape)
(tape-list->string (cdr (tape-after tape))))))
(let* ([tape (tm-config-tape tm)]
[before (reverse (tape-before tape))]
[after (cdr (tape-after tape))])
(string-split
(apply string-append
(map (λ (s) (if (eq? s BLANK) " " (format "~a" s)))
(append before (list (tape-head tape)) after))))))
;; program-related stuff
......@@ -181,10 +183,10 @@
(> (tm-config-steps tm) MAX-STEPS))
(error (format "TM still running after ~a steps; double-check for possible infinite loop"
MAX-STEPS)))
(printf "~a\n\t" (stmt->string (vector-ref (tm-config-program tm)
(tm-config-line-no tm))))
;(printf "~a\n\t" (stmt->string (vector-ref (tm-config-program tm)
; (tm-config-line-no tm))))
(step! tm)
(print-tape tm)
;(print-tape tm)
;(printf "tape position: ~a" (tape-pos (tm-config-tape tm)))
(if (not (eq? (tm-config-state tm) 'running))
(tm-config-state tm)
......@@ -199,4 +201,3 @@
(define (set-input! tm input)
(set-tm-config-tape! tm (initial-tape-for input)))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment