Last active
July 28, 2017 16:52
-
-
Save Joseph-Bake/6587b87fc37ebc79c821fde9a663dcd6 to your computer and use it in GitHub Desktop.
ふぃっしゅ数ver.3
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
type I = Integer | |
data F3 = S [I] | SS I deriving Show | |
sss :: [F3] -> I -> I | |
sss [] _ = 0 | |
sss (S []:ns) x = sss ns x | |
sss [S [1]] x = fpow f x x where f y = y+1 | |
sss (S (1:ns):nss) x = fpow (sss (S ns:nss)) x x | |
sss (S (n:ns):nss) x = sss (S (n'++ns):nss) x where n'=replicate (fromIntegral x) (n-1) | |
sss (SS 1:nss) x = sss (S [x]:nss) x | |
sss (SS n:nss) x = sss (n'++nss) x where n' = replicate (fromIntegral x) (SS (n-1)) | |
fpow :: (a->a) -> I -> (a->a) | |
fpow f 1 = f | |
fpow f n = f.fpow f (n-1) | |
main :: IO() | |
main = print$fpow (sss l632) 63 3 where l632 = replicate 63 (SS 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment