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
any-str.pir p5chop implementation #351
Comments
From @azawawiHello, Here is the p5chop patch that makes our tests pass the first 4 tests. ./perl6 t/spec/S29-str/p5chop.t 2>&1 | head Thanks, Index: src/builtins/any-str.pir--- src/builtins/any-str.pir (revision 31564) @@ -79,7 +79,29 @@ +=item p5chop +=cut our Str method Str::chop ( Str $string: ) |
From @azawawiAttaching the patch file |
From @azawawistr_p5chop.patchIndex: src/builtins/any-str.pir
===================================================================
--- src/builtins/any-str.pir (revision 31564)
+++ src/builtins/any-str.pir (working copy)
@@ -21,7 +21,7 @@
.namespace []
.sub 'onload' :anon :init :load
$P0 = get_hll_namespace ['Any']
- '!EXPORT'('capitalize chop chars index lc lcfirst rindex ord substr uc ucfirst', 'from'=>$P0)
+ '!EXPORT'('capitalize chop p5chop chars index lc lcfirst rindex ord substr uc ucfirst', 'from'=>$P0)
.end
@@ -79,7 +79,29 @@
.return ($I0)
.end
+=item p5chop
+
+ our Char multi P5emul::Str::p5chop ( Str $string is rw )
+ our Char multi P5emul::Str::p5chop ( Str *@strings = ($+_) is rw )
+
+ Trims the last character from C<$string>, and returns it. Called with a
+ list, it chops each item in turn, and returns the last character
+ chopped.
+=cut
+
+.sub 'p5chop' :method :multi(_)
+ .local string tmps
+ .local string lastchar
+
+ tmps = self
+ substr lastchar, tmps, -1
+ chopn tmps, 1
+ self = tmps
+
+ .return(lastchar)
+.end
+
=item chop
our Str method Str::chop ( Str $string: )
|
@azawawi - Status changed from 'new' to 'open' |
From @azawawiAttached is the implementation of p5chop for any-list.pir Together they make t/spec/S29-str/p5chop.t succeed with all of its ./ahmad & |
From @azawawip5chop_lists.patchIndex: src/builtins/any-list.pir
===================================================================
--- src/builtins/any-list.pir (revision 31798)
+++ src/builtins/any-list.pir (working copy)
@@ -21,7 +21,7 @@
.namespace ['Any']
.sub 'onload' :anon :init :load
$P0 = get_hll_namespace ['Any']
- '!EXPORT'('abs', 'from'=>$P0)
+ '!EXPORT'('abs p5chop', 'from'=>$P0)
.end
@@ -43,7 +43,29 @@
.return ($I0)
.end
+=item p5chop
+=cut
+.namespace ['Any']
+.sub 'p5chop' :method :multi(_)
+ .local string tmps
+ .local string lastchar
+ .local pmc it
+
+ $P0 = self.'list'()
+ it = $P0.'iterator'()
+ loop:
+ unless it goto done
+ $P0 = shift it
+ tmps = $P0
+ substr lastchar, tmps, -1
+ chopn tmps, 1
+ $P0 = tmps
+ goto loop
+ done:
+ .return(lastchar)
+.end
+
=item join
=cut
|
From @azawawiPlease use the latest any-list.pir patch. It works perfectly. No need On Wed Oct 08 14:03:03 2008, ahmadz wrote:
|
From @moritzFirst of all thanks for the patch. As mentioned on IRC I'm not too happy with applying these patches until Here's why: $ perl -wle 'chop "xy"' In Perl 6 a string is immutable. The way that string modifying functions So this patch is basically cheating by modifying an object that should Which is why I'll wait with applying these patches until the assignment I apologize for not being clearer on these issues before. Moritz |
From @pmichaudI'm going to go ahead and mark this ticket as "resolved" for now -- I invite new implementations of p5chop and p5chomp, especially if they Thanks! Pm |
@pmichaud - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#59552 (status was 'resolved')
Searchable as RT59552$
The text was updated successfully, but these errors were encountered: