Skip to content

Instantly share code, notes, and snippets.

View awpr's full-sized avatar

Andrew Pritchard awpr

  • Mountain View, CA
View GitHub Profile
@awpr
awpr / brainfuck.lisp
Created March 30, 2011 08:02
Lisp macros to convert brainfuck code into lisp code
; the zipper storing the interpreter's memory
(defvar *memory* (cons () (loop for i from 1 to 32768 collecting 0)))
; convenience function to reset global memory to all zeros
(defun reset-memory ()
(setf *memory* (cons () (loop for i from 1 to 32768 collecting 0))))
(defmacro with-blank-memory (&rest body)
`(let ((*memory* (cons () (loop for i from 1 to 32768 collecting 0))))
,@body))
; the forward portion of the memory zipper
(defmacro forward ()