Created
December 7, 2017 09:35
-
-
Save alandipert/a15a83cb49d9cabf95781b7d987bbcab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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