… | |
… | |
2 | |
2 | |
3 | use Coro; |
3 | use Coro; |
4 | use Coro::Cont; |
4 | use Coro::Cont; |
5 | |
5 | |
6 | sub mul23 : Cont { |
6 | sub mul23 : Cont { |
7 | result 2*shift; |
7 | yield 2*shift; |
8 | result 3*shift; |
8 | yield 3*shift; |
9 | } |
9 | } |
10 | |
10 | |
11 | my %hash = (1,10,2,20,3,30); |
11 | my %hash = (1,10,2,20,3,30); |
12 | |
12 | |
13 | %hash = map mul23($_), %hash; |
13 | %hash = map mul23($_), %hash; |
… | |
… | |
18 | |
18 | |
19 | sub badrand : Cont { |
19 | sub badrand : Cont { |
20 | my $seed = 1; |
20 | my $seed = 1; |
21 | while() { |
21 | while() { |
22 | $seed = $seed * 121 % 97; |
22 | $seed = $seed * 121 % 97; |
23 | result $seed % $_[0]; |
23 | yield $seed % $_[0]; |
24 | } |
24 | } |
25 | } |
25 | } |
26 | |
26 | |
27 | print badrand($_), " " for 1..30; print "\n"; |
27 | print badrand($_), " " for 1..30; print "\n"; |