Skip to content

Instantly share code, notes, and snippets.

@Joseph-Bake
Last active July 19, 2017 19:43
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/a7a59e7d338bf25362c321f0c864c989 to your computer and use it in GitHub Desktop.
Save Joseph-Bake/a7a59e7d338bf25362c321f0c864c989 to your computer and use it in GitHub Desktop.
急増加関数もどき
type I = Integer
pfgh :: [I] -> I -> I
pfgh list x | null l2 = x+1
| null l1 = fpow (pfgh (head list -1 : tail l2)) x x
| otherwise = pfgh (init l1 ++ [x] ++ (head l2 -1) : tail l2) x
where
(l1,l2) = span (<=0) list
fpow :: (a -> a) -> I -> (a -> a)
fpow _ 0 = id
fpow f x = f. fpow f (x-1)
toOI :: I -> I
toOI x = pfgh (replicate (fromIntegral x) x) x
main :: IO()
main = print $ fpow toOI 64 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment