Last active
August 16, 2016 08:36
-
-
Save lattenwald/bc97a668641df7e77ef0 to your computer and use it in GitHub Desktop.
Haskell triangle numbers
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
-- This is even slower than triangleNumsAlt, but this is exactly | |
-- THE function where I grocked lazy lists | |
triangleNums = map fst triangleNums' | |
where | |
triangleNums' = (1, 2) : map (\(n, i) -> (n+i, i+1)) triangleNums' | |
triangleNumsAlt = map (\i -> i * (i+1) `div` 2) [1..] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment