Skip to content

Instantly share code, notes, and snippets.

@ugexe
Last active April 11, 2019 02:55
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 ugexe/94f0b84848ed869720e6d214a08674c7 to your computer and use it in GitHub Desktop.
Save ugexe/94f0b84848ed869720e6d214a08674c7 to your computer and use it in GitHub Desktop.
Polyglot Perl 5/6 pascals triangle
my @ARGV = do { sub eval { &EVAL(@_) }; eval( ("0" and q|@*ARGS| or q|@ARGV|) ) };
my @state = (1,);
for (1 .. @ARGV[0]) {
print(join(" ", @state), "\n");
my @row = map &{ sub ($_) { @state[$_] + (@state[$_ + 1] // 0) } }.(), (0 .. ($_ - 2));
@state = ();
push(@state, 1);
push(@state, $_) for @row;
push(@state, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment