相关疑难解决方法(0)

关于懒惰 [ RAKU ]

在 Raku 文档中指出,gather-take 构造正在被惰性评估。在下面的例子中,我很难对结构的懒惰得出结论:

say 'Iterate to Infinity is : ', (1 ... Inf).WHAT;

say 'gather is : ', gather {
    take 0;
    my ($last, $this) = 0, 1;

    loop {
        take $this;
        ($last, $this) = $this, $last + $this;
    }
}.WHAT;

say '------------------------------------';

my @f1 = lazy gather {
    take 0;
    my ($last, $this) = 0, 1;

    loop {
        take $this;
        ($last, $this) = $this, $last + $this;
    }
}

say '@f1         : ', @f1.WHAT;
say '@f1 is lazy …
Run Code Online (Sandbox Code Playgroud)

arrays lazy-evaluation rakudo lazy-sequences raku

7
推荐指数
1
解决办法
162
查看次数

标签 统计

arrays ×1

lazy-evaluation ×1

lazy-sequences ×1

raku ×1

rakudo ×1