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
man, max should accept code block that defines ordering #653
Comments
From dave.whipp@gmail.comAccording to S29, the "min" and "max" methods should accept the same say "{(1..10).sort: { ($_-3) * ($_-5) }}";
say (1..10).min: { ($_-3) * ($_-5) };
The former works as expected: the latter fails: % ./perl6 -e 'say (1..10).min: { ($_-3) * ($_-5) }' |
From @bacekDave Whipp wrote:
Attached patch for fixing Range.min, max and minmax. Spectest updated in r25027. -- |
From @bacekrange_minmax.patchcommit 765c12dc6eb733b87e190ce39519af978ad66a79
Author: Vasily Chekalkin <bacek@bacek.com>
Date: Mon Jan 26 09:20:45 2009 +1100
Proper implement min, max and minmax on Ranges.
diff --git a/languages/perl6/src/classes/Range.pir b/languages/perl6/src/classes/Range.pir
index a3bc69e..9298f89 100644
--- a/languages/perl6/src/classes/Range.pir
+++ b/languages/perl6/src/classes/Range.pir
@@ -136,19 +136,43 @@ just return a clone of the Range.
.namespace ['Range']
-.sub 'max' :method
+.sub 'max' :method :multi(_)
+ .param pmc by :optional
+ .param int has_by :opt_flag
+ if has_by goto have_by
.tailcall self.'to'()
+
+ have_by:
+ # Flatten range and delegate call Array.max
+ $P0 = self.'list'()
+ .tailcall $P0.'max'(by)
.end
-.sub 'min' :method
+.sub 'min' :method :multi(_)
+ .param pmc by :optional
+ .param int has_by :opt_flag
+ if has_by goto have_by
.tailcall self.'from'()
+
+ have_by:
+ # Flatten range and delegate call Array.min
+ $P0 = self.'list'()
+ .tailcall $P0.'min'(by)
.end
-.sub 'minmax' :method
+.sub 'minmax' :method :multi(_)
+ .param pmc by :optional
+ .param int has_by :opt_flag
+ if has_by goto have_by
$P0 = self.'from'()
$P1 = self.'to'()
$P2 = get_hll_global 'list'
.tailcall $P2($P0, $P1)
+
+ have_by:
+ # Flatten range and delegate call Array.minmax
+ $P0 = self.'list'()
+ .tailcall $P0.'minmax'(by)
.end
|
The RT System itself - Status changed from 'new' to 'open' |
From @jnthnOn Sun Jan 25 09:09:51 2009, dave.whipp@gmail.com wrote:
Both min and max now have a single-arity form as of git 44c4879, which Thanks, Jonathan |
@jnthn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#62742 (status was 'resolved')
Searchable as RT62742$
The text was updated successfully, but these errors were encountered: