有点变态的perl6语法?
你需要多少时间习惯?----------------------------------------------------------------------
say [+] 1, 2, 3; # 6
say [+] (); # 0
say [~] <a b>; # ab
say [**] 2, 3, 4; # 2417851639229258349412352
[\+] 1, 2, 3, 4 # 1, 3, 6, 10
[\**] 2, 3, 4 # 4, 81, 2417851639229258349412352
if [<=] @list {
say "ascending order";
}
----------------------------------------------------------------------
if [==] @nums { say "all nums in @nums are the same" }
elsif [<]@nums { say "@nums is in strict ascending order" }
elsif [<=] @nums { say "@nums is in ascending order"}
----------------------------------------------------------------------
subset Squares of Int where { .sqrt.int**2 == $_ };
multi sub square_root(Squares $x --> Int) {
return $x.sqrt.int;
}
multi sub square_root(Num $x --> Num) {
return $x.sqrt;
}
----------------------------------------------------------------------
my @integers = 0..*;
for @integers -> $i {
say $i;
last if $i % 17 == 0;
}
my @even = map { 2 * $_ }, 0..*;
my @stuff = gather {
for 0 .. Inf {
take 2 ** $_;
}
}
----------------------------------------------------------------------
my $file = open '/etc/passwd', :r;
for $file.lines -> $line {
say $line;
}
---------------------------------------------------------------------- Perl6 has some new features, those are what it should have, since most of them have owned by other popular languages like Python/Ruby while not Perl5.
Personally I best wish Perl6 come soon. Everything has been getting improved like Perl, but won't us?
Orchid in Ubuntu 多看几眼就习惯了,习惯了就会觉得好了 比较直观,很好理解。 蛋疼
关键字越多,记忆难度越大,花在代码本省的书写上的时间就越多,花在逻辑分析上的时间越少 不仅需要一本from c to perl,更需要一本from perl5 to perl6 http://bbs2.chinaunix.net/images/smilies/icon_mrgreen.gif 原帖由 ttcn_cu 于 2009-12-22 20:46 发表 http://bbs3.chinaunix.net/images/common/back.gif
蛋疼
关键字越多,记忆难度越大,花在代码本省的书写上的时间就越多,花在逻辑分析上的时间越少
谬论 还是比较喜欢Perl的自然语言特性。http://bbs2.chinaunix.net/images/smilies/icon_lol.gif 语法很好。但是短期内还进入不了生产环境。
估计5的语法会慢慢过渡到6的。