Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add .min/.max to Sets/SetHashes for consistency
  • Loading branch information
lizmat committed Apr 13, 2014
1 parent f9c9487 commit 4f3553d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/Set.pm
@@ -1,8 +1,12 @@
my class Set does Setty {
has Int $!total;
has Int $!min;
has Int $!max;
has $!WHICH;

method total { $!total //= %!elems.elems }
method total (--> Int) { $!total //= %!elems.elems }
method min (--> Int) { $!min //= %!elems.elems ?? 1 !! Inf }
method max (--> Int) { $!max //= %!elems.elems ?? 1 !! -Inf }
submethod WHICH {
$!WHICH := self.^name ~ '|' ~ %!elems.keys.sort if !$!WHICH.defined;
$!WHICH
Expand Down
2 changes: 2 additions & 0 deletions src/core/Setty.pm
Expand Up @@ -8,6 +8,8 @@ my role Setty does QuantHash {
method kv { %!elems.values X, True }
method elems(--> Int) { %!elems.elems }
method total(--> Int) { %!elems.elems }
method min(--> Int) { %!elems.elems ?? 1 !! Inf }
method max(--> Int) { %!elems.elems ?? 1 !! -Inf }
method exists ($k --> Bool) { # is DEPRECATED doesn't work in settings
DEPRECATED("the :exists adverb");
self.exists_key($k);
Expand Down

0 comments on commit 4f3553d

Please sign in to comment.