Skip to content

Instantly share code, notes, and snippets.

@g000001
Last active September 13, 2022 01:28
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 g000001/af5268faac15491f9dccfd9f4e2d9250 to your computer and use it in GitHub Desktop.
Save g000001/af5268faac15491f9dccfd9f4e2d9250 to your computer and use it in GitHub Desktop.
Tarai(inlined)
(defun tarai (x y z)
(declare (optimize (speed 3) (debug 0) (safety 0)))
(labels ((tarai (x y z)
(declare (fixnum x y z))
(the fixnum
(if (> x y)
(tarai (tarai (1- x) y z)
(tarai (1- y) z x)
(tarai (1- z) x y))
y))))
(declare (inline tarai))
(tarai x y z)))
(compile 'tarai)
(princ (time (tarai 14 7 0)))
(terpri)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment