Created
June 16, 2025 01:35
-
-
Save g000001/bdefc337aae33d5a192613c92c0b5885 to your computer and use it in GitHub Desktop.
Tarai (TAO/ELIS)
This file contains hidden or 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
(de tarai (x y z) | |
(cond ((> x y) | |
(& (:aux _ans) | |
(&tarai ,(tarai (1- x) y z) | |
,(tarai (1- y) z x) | |
,(tarai (1- z) x y) | |
_ans) | |
_ans)) | |
(t y) )) | |
(defrel &tarai | |
(( _x _y _z _ans) | |
(:aux _a0 _a1 _a2) | |
(> _x _y) ! | |
(&tarai ,[_x - 1] _y _z _a0) | |
(&tarai ,[_y - 1] _z _x _a1) | |
(&tarai ,[_z - 1] _x _y _a2) | |
(== _ans ,[_a0 :tarai _a1 _a2])) | |
(( _x _y _z _y) | |
(not (> _x _y)) !)) | |
(defmethod (integer :tarai) (y z) | |
(cond ([self > y] | |
(tarai [[self - 1] :tarai y z] | |
[[y - 1] :tarai z self] | |
[[z - 1] :tarai self y] )) | |
(t y) )) | |
(tarai 12 6 0) | |
→ 12 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment