I would like to (quickly) determine if one array contains all the elements of another array, taking into account that the arrays may have repeated elements.
Thus, I tried something like this:
alice = %w(a a a b)
bob = %w(a a b c d e)
alice & bob => ["a", "b"]
alice - bob => []
But what I would like is an operator that will let me determine that bob does not include all the elements of alice, because bob doesn't have enough "a" characters.
alice.each { |x| bob.delete(x) { return false } }but the first.delete(x)removes all the occurrences of x. This led to looping comparisons which look really un-ruby-like, so I figured there was probably a simple operator already written. Apparently not.