A multiset (bag) implementation in Crystal.
Add this to your application's shard.yml
:
dependencies:
multiset:
github: tcrouch/multiset.cr
require "multiset"
ms1 = Multiset{1, 1}
ms1 << 2 # => Multiset{1, 1, 2}
ms1.merge [3, 4] # => Multiset{1, 1, 2, 3, 4}
ms2 = Multiset.new [2, 3, 4]
ms2.subset_of?(ms1) # => true
ms1 & ms2 # => Multiset{2, 3, 4}
crystal spec
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Author: tcrouch
Source Code: https://github.com/tcrouch/multiset.cr
License: MIT license