Today I noticed that the sequence 'A' ... 'AA' contains only one element:> 'A' ... 'AA'(A)I thought it would contain 27: the alphabet plus the final AA.If I explicitly provide a generator, it does:> 'A', *.succ ... 'AA'(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AA)The docs say that the default generator is either *.succ or *.pred depending on how the end points compare. But:> 'A' cmp 'AA'LessSo it seems I should be getting the *.succ generator by default. I'm definitely not getting the *.pred generator:> 'A', *.pred ... 'AA'Decrement out of range in whatevercode at <unknown file> line 1What's going on here? 解决方案 see which code it is used: rakudo/operatorsyour code is very similar to"A", *.succ ...^ * gt "AA"("B" gt "AA" is True)and code by Curt Tilmes is similar to"A", *.succ ...^ {$_ gt "ZZ" or .chars > "ZZ".chars}"A", *.succ ...^ {$_ gt "YY" or .chars > "YY".chars}("Z" gt "YY" and "AAA".chars > "ZZ".chars are True ) 这篇关于为什么 Perl 6 序列 'A' ... 'AA' 只有一个元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-23 01:33