Jump to content

Babylonian spiral: Difference between revisions

m
→‎{{header|Raku}}: rephrase logic, less bracketing
m (→‎{{header|Raku}}: rephrase logic, less bracketing)
Line 486:
<syntaxhighlight lang="raku" line>sub babylonianSpiral (\nsteps) {
my @squareCache = (0..nsteps).hyper.map: *²;
my @dxys = [[0, 0], [0, 1]];
my $dsq = 1;
 
Line 495:
until @candidates.elems {
$dsq++;
for @squareCache.kv -> \i, \a {
last if a > $dsq / 2;
for reverse (0 .. $dsq.sqrt.ceiling) -> \j {
last if ($dsq > (a + my \b = @squareCache[j] ) < $dsq;
next if (($dsq != a + b) == $dsq) {;
@candidates.append: [ [i, j], [-i, j], [i, -j], [-i, -j],
[j, i], [-j, i], [j, -i], [-j, -i] ]
}
}
}
2,392

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.