我试图在Perl6中创建一个数组,该数组具有两个与Perl5中相同的范围:
my @cols = (3..9, 11..16);
use Data::Printer:from<Perl5>;
p @cols; exit;
但是,这会创建一个二维数组
[
[0] [
[0] 3,
[1] 4,
[2] 5,
[3] 6,
[4] 7,
[5] 8,
[6] 9
],
[1] [
[0] 11,
[1] 12,
[2] 13,
[3] 14,
[4] 15,
[5] 16
]
]
当它应该是一维数组时,例如(3..9, 11..16)
应该在Perl5中:
[
[0] 3,
[1] 4,
[2] 5,
[3] 6,
[4] 7,
[5] 8,
[6] 9,
[7] 11,
[8] 12,
[9] 13,
[10] 14,
[11] 15,
[12] 16,
[13] 17,
[14] 18,
[15] 19,
[16] 20
]
我当然可以使用append
轻松解决这个问题,但是如何只用一行代码在Perl6中获得(3..9, 11..16)
的Perl5结果呢?