Created
August 18, 2017 12:36
-
-
Save jnthn/270633f76db049a52999cdb63a00df27 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
my class Node { | |
has $.value; | |
has $.next; | |
} | |
for 1..4 -> $attempt { | |
my $head = Node; | |
await start { | |
for 1..10000 -> $i { | |
loop { | |
my $orig = $head; | |
my $next = Node.new(value => $i, next => $orig); | |
last if cas($head, $orig, $next) === $orig; | |
} | |
} | |
} xx 4; | |
my $total = 0; | |
my $cur = $head; | |
while $cur { | |
$total += $cur.value; | |
$cur = $cur.next; | |
} | |
say $total == 4 * [+](1..10000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment