Skip to content

Instantly share code, notes, and snippets.

@VictorTaelin
Created August 16, 2018 18:40
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 VictorTaelin/bc0e8b38f93130a083b8de293d9cc7f5 to your computer and use it in GitHub Desktop.
Save VictorTaelin/bc0e8b38f93130a083b8de293d9cc7f5 to your computer and use it in GitHub Desktop.
Composition by sharing doesn't work in Haskell
comp :: Int -> (a -> a) -> (a -> a)
comp 0 f x = x
comp n f x = comp (n `div` 2) g (r x)
where g = f . f
r = if even n then id else f
main :: IO ()
main = print (comp (2 ^ 20) not True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment