-
-
Save VictorTaelin/bc0e8b38f93130a083b8de293d9cc7f5 to your computer and use it in GitHub Desktop.
Composition by sharing doesn't work in Haskell
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
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