1 (define (bf-dptr-forward data dptr)
4 (define bf-instructions
6 (cons (">" . (lambda (data dptr) 'a)))))
8 (define (bf program-string)
9 ;; (let ((matching-brackets (bf-scan-bracket program-string)))
11 ((data (make-vector 3000 0))
13 (next-instruction-i 0))
14 (if (< next-instruction-i (string-length program-string))
15 (let ((next-instruction
16 (string-ref program-string next-instruction-i)))
17 (case next-instruction
19 (run-loop data (1+ data-pointer) (1+ next-instruction-i)))
21 (run-loop data (1- data-pointer) (1+ next-instruction-i)))
23 (vector-set! data data-pointer
24 (1+ (vector-ref data data-pointer)))
25 (run-loop data data-pointer (1+ next-instruction-i)))
27 (vector-set! data data-pointer
28 (1- (vector-ref data data-pointer)))
29 (run-loop data data-pointer (1+ next-instruction-i)))
31 (display (vector-ref data data-pointer))
32 (run-loop data data-pointer (1+ next-instruction-i)))
34 (vector-set! data data-pointer
35 (char->integer (read-char)))
36 (run-loop data data-pointer (1+ next-instruction-i)))