Category talk:Wren-set: Difference between revisions

→‎Source code: Added sameDistinct and allDistinct methods to Bag class.
m (→‎Source code: Added quotes to 'lang' attribute.)
(→‎Source code: Added sameDistinct and allDistinct methods to Bag class.)
Line 499:
// as the elements of another Bag and vice versa.
!=(other) { !(this == other) }
 
// Returns whether or not the distinct elements of this instance are the same
// as the distinct elements of another Bag and vice versa.
sameDistinct(other) {
if (other.type != Bag) Fiber.abort("Argument must be a Bag.")
if (_m.count != other.count) return false
for (k in _m.keys) {
if (!other.contains(k)) return false
}
return true
}
 
// Returns whether or not all elements of this instance are distinct.
allDistinct { _m.values.all { |v| v == 1 } }
 
// Returns the string representation of the current instance enclosed in angle brackets
9,482

edits