Created
October 30, 2014 05:24
-
-
Save depressed-pho/a2a03844653cdae428a3 to your computer and use it in GitHub Desktop.
Tarai function in Haskell
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
main :: IO () | |
main = print (tarai 13 8 0) | |
tarai :: Int -> Int -> Int -> Int | |
tarai x y z | |
| x <= y = y | |
| otherwise = tarai (tarai (x-1) y z) | |
(tarai (y-1) z x) | |
(tarai (z-1) x y) | |
{- | |
% ghc --make -O3 Tarai.hs | |
[1 of 1] Compiling Main ( Tarai.hs, Tarai.o ) | |
Linking Tarai ... | |
% time ./Tarai | |
13 | |
./Tarai 0.00s user 0.00s system 95% cpu 0.004 total | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment