Skip to content

Instantly share code, notes, and snippets.

@Joseph-Bake
Last active July 28, 2017 16:52
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 Joseph-Bake/6587b87fc37ebc79c821fde9a663dcd6 to your computer and use it in GitHub Desktop.
Save Joseph-Bake/6587b87fc37ebc79c821fde9a663dcd6 to your computer and use it in GitHub Desktop.
ふぃっしゅ数ver.3
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