Created
November 8, 2015 00:36
-
-
Save JamesMcMahon/7fdd0570853677048168 to your computer and use it in GitHub Desktop.
Haskell lazy performance test
This file contains hidden or 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
#!/usr/bin/env runhaskell | |
maximum' :: (Ord a) => [a] -> a | |
maximum' [] = error "maximum of empty list" | |
maximum' [x] = x | |
maximum' (x:xs) = max x (maximum' xs) | |
main :: IO () | |
main = do | |
-- print (maximum' [3, 5, 7, 3, 6]) | |
print (maximum' [1..6543210]) |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
print(max([i for i in range(6543210)])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why is the Python code so much faster? Most likely doing something wrong in the Haskell code just not familiar enough with the language to figure it out.