Skip to content

Instantly share code, notes, and snippets.

@gfldex
Last active October 16, 2016 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfldex/798aa1212070d5bd6205b2ff1900660f to your computer and use it in GitHub Desktop.
Save gfldex/798aa1212070d5bd6205b2ff1900660f to your computer and use it in GitHub Desktop.
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