perl6 - Can you loop a Perl 6 block that's in a variable? -


i keep wanting this:

my $block := {     state $n = 0;     $n++;     last if $n > 3;     };  loop $block; 

or even:

$block.loop; 

i'm not expecting possible sure cool if was.

how find out particular routine comes from?

$ perl6 exit type 'exit' or '^d' > &loop.^name ===sorry!=== error while compiling: undeclared routine:     loop used @ line 1 

using in perl 6, can use seq.from-loop in sink context.
(note repl doesn't put last statement on line sink context)

my $block := {     state $n = 0;     $n++;     last if $n > 3; }  seq.from-loop: $block; 
seq.from-loop: {say $++}, {$++ <= 3}; 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -