Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/p6.p6 Secret

Last active October 26, 2017 00:45
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 zoffixznet/70cb09f80a48247839a54b1755575459 to your computer and use it in GitHub Desktop.
Save zoffixznet/70cb09f80a48247839a54b1755575459 to your computer and use it in GitHub Desktop.
sub sleep_sort (*@list where .all >= 0) {
my $channel = Channel.new;
await @list.map: -> $delay {
Promise.start({
sleep $delay / 1000;
$channel.send($delay);
});
};
$channel.close;
return $channel.list;
}
my @a = sleep_sort(3,2,1,5,4) xx 500;
say all(@a).elems == 5 ?? "pass" !! "fail";
say now - INIT now;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment