Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl6
- use v6;
- sub swap(Array @xs is copy, $pos = 1) {
- return @xs if +@xs <= 1;
- @xs[$pos .. @xs.end].unshift(reverse @xs[0..$pos]);
- }
- my @given = 1,3,5 ... 21;
- my @swapped = swap(@given, 2);
- say "BEFORE :" ~ ~@given;
- say "AFTER :" ~ ~@swapped;
- [rml@glamdring mathoms]$ ./varfun.pl
- Nominal type check failed for parameter '@xs'; expected Positional[Array] but got Array instead
- in 'swap' at line 5:./varfun.pl
- in main program body at line 11:./varfun.pl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement