Abelian sandpile model: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
No edit summary
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 289:
target_link_libraries(abelian_sandpile xtensor ${OIIO})
</pre>
 
=={{header|Fōrmulæ}}==
 
In [https://wiki.formulae.org/Abelian_sandpile_model this] page you can see the solution of this task.
 
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text ([http://wiki.formulae.org/Editing_F%C5%8Drmul%C3%A6_expressions more info]). Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for transportation effects more than visualization and edition.
 
The option to show Fōrmulæ programs and their results is showing images. Unfortunately images cannot be uploaded in Rosetta Code.
 
=={{header|Forth}}==
Line 512 ⟶ 504:
 
end program</lang>
 
=={{header|Fōrmulæ}}==
 
In [https://wiki.formulae.org/Abelian_sandpile_model this] page you can see the solution of this task.
 
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text ([http://wiki.formulae.org/Editing_F%C5%8Drmul%C3%A6_expressions more info]). Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for transportation effects more than visualization and edition.
 
The option to show Fōrmulæ programs and their results is showing images. Unfortunately images cannot be uploaded in Rosetta Code.
 
=={{header|Go}}==
Line 1,083:
[http://alahonua.com/temp/Abel_Z_color_100000.png Link to PNG output file for N=100000 ie. AbelSand.move(100000)] <br />
[http://alahonua.com/temp/Abel_Z_color_1000000.png Link to PNG output file (run time >90 min) for N=1000000 (move(1000000))]
 
=={{header|Pascal}}==
{{works with|Free Pascal}}
Line 1,362 ⟶ 1,363:
select undef, undef, undef, 0.1; # comment out for full speed
}</lang>
 
=={{header|Perl 6}}==
{{works with|Rakudo|2019.07.1}}
Defaults to a stack of 1000 and showing progress. Pass in a custom stack size if desired and -hide-progress to run without displaying progress (much faster.)
 
<lang perl6>sub cleanup { print "\e[0m\e[?25h\n"; exit(0) }
 
signal(SIGINT).tap: { cleanup(); exit(0) }
 
unit sub MAIN ($stack = 1000, :$hide-progress = False );
 
my @color = "\e[38;2;0;0;0m█",
"\e[38;2;255;0;0m█",
"\e[38;2;255;255;0m█",
"\e[38;2;0;0;255m█",
"\e[38;2;255;255;255m█"
;
 
my ($h, $w) = qx/stty size/.words».Int;
my $buf = $w * $h;
my @buffer = 0 xx $buf;
my $done;
 
@buffer[$w * ($h div 2) + ($w div 2) - 1] = $stack;
 
print "\e[?25l\e[48;5;232m";
 
repeat {
$done = True;
loop (my int $row; $row < $h; $row = $row + 1) {
my int $rs = $row * $w; # row start
my int $re = $rs + $w; # row end
loop (my int $idx = $rs; $idx < $re; $idx = $idx + 1) {
if @buffer[$idx] >= 4 {
++@buffer[ $idx - $w ] if $row > 0;
++@buffer[ $idx - 1 ] if $idx - 1 > $rs;
++@buffer[ $idx + $w ] if $row < $h - 1;
++@buffer[ $idx + 1 ] if $idx + 1 < $buf;
@buffer[ $idx ] -= 4;
$done = False;
}
}
}
unless $hide-progress {
print "\e[1;1H", @buffer.map( { @color[$_ min 4] } ).join
}
} until $done;
 
print "\e[1;1H", @buffer.map( { @color[$_ min 4] } ).join;
 
cleanup;</lang>
 
Passing in 2048 as a stack size results in: [https://github.com/thundergnat/rc/blob/master/img/Abelian-sandpile-model-perl6.png Abelian-sandpile-model-perl6.png] (offsite .png image)
 
=={{header|Phix}}==
Line 1,681 ⟶ 1,629:
0 0 0 0 0 0 0 0 0 0
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
{{works with|Rakudo|2019.07.1}}
Defaults to a stack of 1000 and showing progress. Pass in a custom stack size if desired and -hide-progress to run without displaying progress (much faster.)
 
<lang perl6>sub cleanup { print "\e[0m\e[?25h\n"; exit(0) }
 
signal(SIGINT).tap: { cleanup(); exit(0) }
 
unit sub MAIN ($stack = 1000, :$hide-progress = False );
 
my @color = "\e[38;2;0;0;0m█",
"\e[38;2;255;0;0m█",
"\e[38;2;255;255;0m█",
"\e[38;2;0;0;255m█",
"\e[38;2;255;255;255m█"
;
 
my ($h, $w) = qx/stty size/.words».Int;
my $buf = $w * $h;
my @buffer = 0 xx $buf;
my $done;
 
@buffer[$w * ($h div 2) + ($w div 2) - 1] = $stack;
 
print "\e[?25l\e[48;5;232m";
 
repeat {
$done = True;
loop (my int $row; $row < $h; $row = $row + 1) {
my int $rs = $row * $w; # row start
my int $re = $rs + $w; # row end
loop (my int $idx = $rs; $idx < $re; $idx = $idx + 1) {
if @buffer[$idx] >= 4 {
++@buffer[ $idx - $w ] if $row > 0;
++@buffer[ $idx - 1 ] if $idx - 1 > $rs;
++@buffer[ $idx + $w ] if $row < $h - 1;
++@buffer[ $idx + 1 ] if $idx + 1 < $buf;
@buffer[ $idx ] -= 4;
$done = False;
}
}
}
unless $hide-progress {
print "\e[1;1H", @buffer.map( { @color[$_ min 4] } ).join
}
} until $done;
 
print "\e[1;1H", @buffer.map( { @color[$_ min 4] } ).join;
 
cleanup;</lang>
 
Passing in 2048 as a stack size results in: [https://github.com/thundergnat/rc/blob/master/img/Abelian-sandpile-model-perl6.png Abelian-sandpile-model-perl6.png] (offsite .png image)
 
=={{header|Rust}}==
Line 1,825 ⟶ 1,827:
</pre>
 
=={{header|VBA}}==
<lang VBA>Sub SetupPile(a As Integer, b As Integer)
10,333

edits