Zhang-Suen thinning algorithm: Difference between revisions

m
→‎{{header|Perl 6}}: removed DEBUG, in-lined source data
(Added Perl example)
m (→‎{{header|Perl 6}}: removed DEBUG, in-lined source data)
Line 3,059:
 
=={{header|Perl 6}}==
Takes the originalSource image from a file that may be based on any characters whose low bits are 0 or 1 (which conveniently includes . and #).
<lang perl6>constantmy DEBUG$source = 1qq:to/EOD/;
................................
.#########.......########.......
.###...####.....####..####......
.###....###.....###....###......
.###...####.....###.............
.#########......###.............
.###.####.......###....###......
.###..####..###.####..####.###..
.###...####.###..########..###..
................................
EOD
 
my @lines = ([.ords X+& 1] for lines$source.split("\n")); # The low bits Just Work.
my \v = +@lines;
my \h = +@lines[0];
Line 3,092 ⟶ 3,103:
@goners1 = seewhite (0,2,4), (2,4,6);
@black[@goners1] = 0 xx *;
say "Ping: {[+] @black} remaining after removing ", @goners1 if DEBUG;
 
@goners2 = seewhite (0,2,6), (0,4,6);
@black[@goners2] = 0 xx *;
say "Pong: {[+] @black} remaining after removing ", @goners2 if DEBUG;
}
 
2,392

edits