flatwhatson
Re:Miguel de Icaza: Learning Unix
on Wednesday September 07, 2011 @08:20AM (#2969250)
In all my years of using and loving (and abusing) the shell, I've never encountered apropos. I'm really amazed that something so fundamental has somehow been left out of the many unix/shell articles (such as this one) that I've read. Anyhow, you've made my day. Thanks!
Re:AWK-ward Ruby
on Wednesday April 27, 2011 @01:17AM (#2488486)
I probably should have replied to rtomayko's comment rather than your own. I'd edit the tree, but it's immutable!
Re:AWK-ward Ruby
on Tuesday April 26, 2011 @11:01PM (#2488199)
Blocks are also available in Perl, in the form of anonymous subroutines. They follow Perlish conventions for argument handling (rather than having a neat inline syntax like Smalltalk or Ruby), but they're most definitely the same thing!
my $block = sub { say "w00t, blocks!" };
my $closure = sub { $block->(); say "w00t, closures!" };
You'll have to look further for something Ruby does that Perl doesn't :)
Re:Joel Spolsky: Can your programming language do this?
on Sunday April 24, 2011 @11:44AM (#2479029)
Here's one more efficient way... use perl!
#!/usr/bin/perl
use Modern::Perl;
use List::Util 'reduce';
sub cook {
my ($i1, $i2, $f) = @_;
say "get the $i1";
$f->($i1);
$f->($i2);
}
cook "lobster", "water", sub { say "pot " . shift };
cook "chicken", "coconut", sub { say "boom " . shift };
my @a = (1, 2, 3);
map { say $_ * 2 } @a;
map { say $_ } @a;
sub my_sum {
reduce { $a + $b } 0, @_;
}
sub my_join {
reduce { $a . $b } "", @_;
}
say "sum " . my_sum(@a);
say "join " . my_join(@a);