« snow | Main | なぞなぞ認証 »

23 January 2008

autobox面白い

autobox は面白いですね。気持ちいい感じに近いかな。

perldoc autobox に書かれている 10->to(1); は以下のようになります。


$ perl -Mautobox -Mautobox::Core -MData::Dumper -le 'print Dumper 10->to(1)'
$VAR1 = [
10,
9,
8,
7,
6,
5,
4,
3,
2,
1
];

それから Perl6::Contexts も加えて、%hash をごにょごにょと。


$ perl -MPerl6::Contexts -Mautobox -Mautobox::Core -le 'my %hash = (foo => 'bar', baz => 'quux'); %hash->keys->sort->reverse->print;'
foo baz

もちろん keys を values に変えることだってできる。


$ perl -MPerl6::Contexts -Mautobox -Mautobox::Core -le 'my %hash = (foo => 'bar', baz => 'quux'); %hash->values->sort->reverse->print;'
quux bar

ハッシュのリファレンスなら Perl6::Contexts はいらないね。


$ perl -Mautobox -Mautobox::Core -le 'my $hash = {foo => 'bar', baz => 'quux'}; $hash->keys->sort->reverse->print;'
foo baz

ぼくはこの書き方好きだな。

参照

TrackBack

TrackBack URL for this entry:
http://bb.lekumo.jp/t/trackback/517129/31023151

Listed below are links to weblogs that reference autobox面白い:

Comments

a concept/wish for a geernic-site generator, if possible:1) finds dates (in various formats!)2) user chooses date-format to which to convert, and to append that to either lead or tail of title/bkmk.can two generators operate upon same url?if yes, then how to set generators' sequence?

Post a comment

Access Ranking

Powered by Six Apart
Sponsored links