aboutsummaryrefslogtreecommitdiff
path: root/challenge-070/stuart-little/raku/ch-1.p6
blob: cbad4f9e3265bd0ba9c412c32e562cba4a539994 (plain)
1
2
3
4
5
6
7
8
9
10
#!/usr/bin/env perl6
use v6;

sub swp(Str $s, Int $c, Int $o where { $c <= $o && $c+$o <= $s.chars }) {
    $s.substr(0,1) ~ $s.substr(1+$o, $c) ~ $s.substr($c+1..$o) ~ $s.substr(1, $c) ~ $s.substr($c+$o+1)
}

say swp(@*ARGS[0], |@*ARGS[1,2].map(*.Int) );

# run as <script> <string count offset>