Last active
October 16, 2016 23:25
-
-
Save gfldex/798aa1212070d5bd6205b2ff1900660f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
my &channelify = | |
%*ENV<RAKUDO_MAX_THREADS>:!exists || %*ENV<RAKUDO_MAX_THREADS>.Int <= 1 | |
?? -> \c { c } | |
!! -> \list, $channel = Channel.new { | |
start { | |
for list { | |
$channel.send($_) | |
} | |
LEAVE $channel.close unless $channel.closed; | |
} | |
$channel.list but role :: { method channel { $channel } } | |
}; | |
my \l1 = gather for 1..100000 { take (1..1000).roll }; | |
multi sub postfix:«⇒»(Positional:D \ll){ | |
channelify ll | |
} | |
.say for (l1⇒ .grep({ .is-prime }))⇒ .sort; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment