Skip to content

Instantly share code, notes, and snippets.

@ap
Created August 27, 2010 23:20
Show Gist options
  • Save ap/554366 to your computer and use it in GitHub Desktop.
Save ap/554366 to your computer and use it in GitHub Desktop.
use List::Util 'reduce';
sub pascal {
my ( $x, @p, @q ) = shift;
push @p, reduce { push @p, $a + $b; $b } 1, @q = @p, @p = () for 1 .. $x - 1;
1, @p;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment