New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
:nth() does not work with :x() or :g in .subst in Rakudo #467
Comments
From @masakThe .subst method in Rakudo r33599 can understand :x()... $ perl6 -e 'say "foo1foo2foo3foo4".subst("foo", "bar", :x(2))' # yes ...and :nth()... $ perl6 -e 'say "foo1foo2foo3foo4".subst("foo", "bar", :nth(2))' # yes ...and :g... $ perl6 -e 'say "foo1foo2foo3foo4".subst("foo", "bar", :g)' # yes ...but not :x() together with :nth()... $ perl6 -e 'say "foo1foo2foo3foo4".subst("foo", "bar", :x(2), ...and not :g together with :nth(). $ perl6 -e 'say "foo1foo2foo3foo4".subst("foo", "bar", :g, :nth(2))' # The above are my personal expectations. The current version of S05 is |
From @moritzOn Sun Dec 07 07:24:07 2008, masak wrote:
Since your personal expectations are the same as mine, I took the liberty to The reasoning behind it is quite simple: I imagine :g to mean the same as for 1 .. $x { (CC'ing p6l, since it defines language semantics, albeit just a bit) |
The RT System itself - Status changed from 'new' to 'open' |
From @pmichaudOn Sun, Dec 07, 2008 at 03:09:30PM -0800, Moritz Lenz via RT wrote:
The problem with this reasoning is that :nth doesn't have to be an :nth(1,2,3,5,8,13) It's not immediately obvious how those forms of :nth would interact The way to do something like "replace every 3rd occurrence" would :nth({ $_ % 3 == 0 }) Another problem is that :x($n) specifies "perform $n substitutions", At the moment I think that :x specifies a constraint on the .subst( $pat, $rep, :nth(1,4,9,16,25,36), :x(4) ) would perform substitutions on the 1st, 4th, 9th, and 16th matches, Pm |
From @moritzIt works now as currently specced, with lots of tests in |
@moritz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#61130 (status was 'resolved')
Searchable as RT61130$
The text was updated successfully, but these errors were encountered: