Created
July 17, 2017 14:42
-
-
Save Joseph-Bake/afab33c823d81c4ccc929ce413f01f86 to your computer and use it in GitHub Desktop.
ベクレミシェフの虫
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 | |
g :: [I] -> I -> I | |
g [] x = x-1 | |
g (0:as) x = g as (f x) where f y = y+1 | |
g (a:as) x = g (clone l1' (x+1)++l2) (x+1) | |
where | |
clone list 1 = list | |
clone list k = list ++ clone list (k-1) | |
(l1,l2) = span (a<=) as | |
l1' = (a-1) : l1 | |
main :: IO() | |
main = print (worm 2) where worm x = g [x] 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment