Skip to content

Instantly share code, notes, and snippets.

@alandipert
Created December 7, 2017 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alandipert/a15a83cb49d9cabf95781b7d987bbcab to your computer and use it in GitHub Desktop.
Save alandipert/a15a83cb49d9cabf95781b7d987bbcab to your computer and use it in GitHub Desktop.
(defmacro run (code evfun)
`((lambda (code)
(declare (optimize (speed 3))
(type (simple-array fixnum (*)) code)
(type function evfun)
(inline ,evfun))
(loop with steps = 0
with ptr = 0
with code = (copy-seq code)
with code-length = (length code)
until (exited? code-length ptr)
do (progn (setf ptr (,evfun code ptr))
(incf (the fixnum steps)))
finally (return steps)))
,code))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment