blob: 47736801f4a6907bf2b202da58da6593720a7158 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#! /usr/bin/env raku
unit sub MAIN ($str is copy where $str ~~ /^<[ a..z A..Z ]>+$/,
:v(:$verbose));
my $index = 0;
loop
{
my $end = $str.chars -1;
my $current = $str.substr($index, 1);
last if $end == -1;
last if $index == $end;
my $next = $str.substr($index +1, 1);
print ": Checking '$current$next' (index $index)" if $verbose;
if $current.lc eq $next.lc && $current ne $next
{
$str.substr-rw($index,2) = "";
say " - replace with nothing -> $str" if $verbose;
$index-- unless $index == 0;
}
else
{
say "" if $verbose;
$index++;
}
}
say $str;
|