Created
July 10, 2016 20:24
-
-
Save etscrivner/1a0292ed7b11ac2249ccc1808f56be0e to your computer and use it in GitHub Desktop.
Hoon for producing triangular/tetrahedral 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
|= number/@ | |
=/ curnum 1 | |
|- ^- (list @) | |
?: (gth curnum number) ~ | |
:_ $(curnum (add 1 curnum)) | |
=< (roll (triangular curnum) add) | |
|% | |
++ iota | |
|= {start/@ end/@} | |
=/ count start | |
|- ^- (list @) | |
?: (gth count end) | |
~ | |
:_ $(count (add 1 count)) | |
count | |
++ triangular | |
|= n/@ | |
=/ next 1 | |
|- ^- (list @) | |
?: (gth next n) ~ | |
:_ $(next (add 1 next)) | |
(roll (iota [1 next]) add) | |
-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment