Skip to content

Instantly share code, notes, and snippets.

@mcmillhj
Created May 22, 2018 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcmillhj/1d2f7d7cdc220453f1e5429890fec819 to your computer and use it in GitHub Desktop.
Save mcmillhj/1d2f7d7cdc220453f1e5429890fec819 to your computer and use it in GitHub Desktop.
multi sub floyds-triangle(1 --> List) { 1 .. 1, }
multi sub floyds-triangle(Int:D $n where * > 1 --> List) {
my $nth-triangle-number = $n * ($n + 1) div 2;
return floyds-triangle2($n - 1), $nth-triangle-number - $n ^.. $nth-triangle-number;
}
say floyds-triangle(5);
# (((((1..1) 1^..3) 3^..6) 6^..10) 10^..15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment