Name: Anonymous 2012-01-20 3:53
If you think Perl is ugly, you don't know how to use it.
Discuss.
Discuss.
->
for essential operations, ugly pseudo shortcuts like $_
which most of the time aren't even shorter, $
aka the ugliest ascii character all over the code for no good reason, ugly syntax for class declarations because OO is tacked on etc.
sub permute (&@) {
my $code = shift;
my @idx = 0..$#_;
while ( $code->(@_[@idx]) ) {
my $p = $#idx;
--$p while $idx[$p-1] > $idx[$p];
my $q = $p or return;
push @idx, reverse splice @idx, $p;
++$q while $idx[$p-1] > $idx[$q];
@idx[$p-1,$q]=@idx[$q,$p-1];
}
}