gpt4 book ai didi

raku - perl6/rakudo : Unable to parse postcircumfix:sym<( )>

转载 作者:行者123 更新时间:2023-12-04 18:51:53 25 4
gpt4 key购买 nike

为什么我会收到此错误消息?

#!perl6
use v6;

my @a = 1..3;
my @b = 7..10;
my @c = 'a'..'d';


for zip(@a;@b;@c) -> $nth_a, $nth_b, $nth_c { ... };


# Output:

# ===SORRY!===
# Unable to parse postcircumfix:sym<( )>, couldn't find final ')' at line 9

最佳答案

Rakudo 尚未实现 lol(“列表列表”)形式,因此无法解析 @a;@b;@c .出于同样的原因,zip还没有包含三个列表的表单。显然,错误消息并不令人敬畏。

目前还没有一个好的解决方法,但这里有一些可以完成工作的东西:

sub zip3(@a, @b, @c) {
my $a-list = flat(@a.list);
my $b-list = flat(@b.list);
my $c-list = flat(@c.list);
my ($a, $b, $c);
gather while ?$a-list && ?$b-list && ?$c-list {
$a = $a-list.shift unless $a-list[0] ~~ ::Whatever;
$b = $b-list.shift unless $b-list[0] ~~ ::Whatever;
$c = $c-list.shift unless $c-list[0] ~~ ::Whatever;
take ($a, $b, $c);
}
}

for zip3(@a,@b,@c) -> $nth_a, $nth_b, $nth_c {
say $nth_a ~ $nth_b ~ $nth_c;
}

关于raku - perl6/rakudo : Unable to parse postcircumfix:sym<( )>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5026451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com