Created
December 9, 2019 22:55
-
-
Save gulan/31219869906230a2f1c49dc507546260 to your computer and use it in GitHub Desktop.
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
| module CombinatorialHierarchy where | |
| {- https://en.wikipedia.org/wiki/Combinatorial_hierarchy | |
| 3, 2^3-1, 2^7-1, 2^127-1 | |
| seq: | |
| 3, 7, 127, 170141183460469231731687303715884105727 | |
| cumulative sum: | |
| 3, 10, 137, 170141183460469231731687303715884105864 | |
| -} | |
| combinatorialHierarchy = cumSum (take 4 (conseq 3)) | |
| where conseq :: Integer -> [Integer] | |
| conseq n = n : conseq (nxt n) | |
| nxt n = 2^n - 1 | |
| cumSum = scanl1 (+) | |
| main = print combinatorialHierarchy | |
| {- | |
| $ ghci CombinatorialHierarchy.hs | |
| ... | |
| > main | |
| [3,10,137,170141183460469231731687303715884105864] | |
| > | |
| -} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment