Skip to content
Browse files

Copy changes to Bag as well.

  • Loading branch information...
1 parent 989dffc commit 425def6617e3786762a07c73343aaf7392f102e5 @colomon colomon committed Dec 5, 2013
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/CORE.setting
View
10 lib/CORE.setting
@@ -2403,10 +2403,11 @@ class Bag does Associative does Baggy {
method default { 0 }
method keys { %!elems.keys }
method values { %!elems.values }
- method elems returns Int { [+] self.values }
+ method elems { %!elems.elems }
+ method total { [+] self.values }
method exists($a) returns Bool { %!elems.exists($a) }
method Bool { %!elems.Bool }
- method Numeric { self.elems }
+ method Numeric { self.total }
method hash { %!elems.hash }
method Set { set self.keys }
method SetHash { SetHash.new(self.keys) }
@@ -2441,7 +2442,10 @@ class Bag does Associative does Baggy {
method ACCEPTS($other) { defined(self) ?? $other ≼ self && self ≼ $other !! $other.^does(self) }
- method Str() { self.defined ?? %!elems.pairs.map({ $_.key xx $_.value }).flat.join(" ") !! nextsame }
+ method Str() {
+ self.defined ?? %!elems.pairs.map({ $_.value == 1 ?? $_.key.gist !! "{$_.key.gist}({$_.value})" }).flat.join(" ")
+ !! nextsame
+ }
method gist() { self.defined ?? "bag({ self.pairs>>.gist.join(', ') })" !! "(Bag)" }
method perl() { self.defined ?? '(' ~ %!elems.perl ~ ').Bag' !! "Bag" }

0 comments on commit 425def6

Please sign in to comment.
Something went wrong with that request. Please try again.