Skip to content

Instantly share code, notes, and snippets.

@masak

masak/nth.diff Secret

Created November 23, 2014 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masak/082fc27b6e270d852e65 to your computer and use it in GitHub Desktop.
Save masak/082fc27b6e270d852e65 to your computer and use it in GitHub Desktop.
my change to make *-1 work in :nth
$ git diff
diff --git a/src/core/Str.pm b/src/core/Str.pm
index 7bfe46d..7448304 100644
--- a/src/core/Str.pm
+++ b/src/core/Str.pm
@@ -621,6 +621,9 @@ my class Str does Stringy { # declared in BOOTSTRAP
my $max = 0;
while @nlist {
my $n = shift @nlist;
+ if $n ~~ WhateverCode {
+ $n = $n(@src + 1);
+ }
fail "Attempt to retrieve negative match :nth($n)" if $n < 1;
if $n > $max { take @src[$n-1]; $max = $n; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment