--- layout: default title: "Multisets" parent: Composite ancestor: Funcons-beta --- [Funcons-beta] : [Multisets.cbs] ----------------------------- ### Multisets (bags)
[
  Type   multisets
  Funcon multiset
  Funcon multiset-elements
  Funcon multiset-occurrences
  Funcon multiset-insert
  Funcon multiset-delete
  Funcon is-submultiset
]
Meta-variables
  GT <: ground-values
Built-in Type
  multisets(GT)
multisets(GT) is the type of possibly-empty finite multisets of elements of GT.
Built-in Funcon
  multiset(_:(GT)*) : =>multisets(GT)
Note that multiset(...) is not a constructor operation. The order of argument values is ignored, but duplicates are significant, e.g., multiset(1, 2, 2) is equivalent to multiset(2, 1, 2), but not to multiset(1, 2) or multiset(2, 1).
Built-in Funcon 
  multiset-elements(_:multisets(GT)) : =>(GT)*
For each multiset MS, the sequence of values V* returned by multiset-elements(MS) contains each element of MS the same number of times as MS does. The order of the values in V* is unspecified, and may vary between multisets.
Assert
  multiset(multiset-elements(S)) == S
Built-in Funcon
  multiset-occurrences(_:GT, _:multisets(GT)) : =>natural-numbers
multiset-occurrences(GV, MS) returns the number of occurrences of GV in MS.
Built-in Funcon
  multiset-insert(_:GT, _:natural-numbers, _:multisets(GT)) : =>multisets(GT)
multiset-insert(GV, N, MS) returns the multiset that differs from MS by containing N more copies of GV.
Built-in Funcon
  multiset-delete(_:multisets(GT), _:GT, _:natural-numbers) : =>multisets(GT)
multiset-delete(MS, GV, N) removes N copies of V from the multiset MS, or all copies of GV if there are fewer than N in MS.
Built-in Funcon
  is-submultiset(_:multisets(GT), _:multisets(GT)) : =>booleans
is-submultiset(MS1, MS2) tests whether every element of MS1 has equal or fewer occurrences in MS1 than in MS2. ____ From the [PLanCompS Project] | [CBS-beta issues...] | [Suggest an improvement...] [Multisets.cbs]: Multisets.cbs "CBS SOURCE FILE" [Funcons-beta]: /CBS-beta/docs/Funcons-beta "FUNCONS-BETA" [Unstable-Funcons-beta]: /CBS-beta/docs/Unstable-Funcons-beta "UNSTABLE-FUNCONS-BETA" [Languages-beta]: /CBS-beta/docs/Languages-beta "LANGUAGES-BETA" [Unstable-Languages-beta]: /CBS-beta/docs/Unstable-Languages-beta "UNSTABLE-LANGUAGES-BETA" [CBS-beta]: /CBS-beta "CBS-BETA" [PLanCompS Project]: https://plancomps.github.io "PROGRAMMING LANGUAGE COMPONENTS AND SPECIFICATIONS PROJECT HOME PAGE" [CBS-beta issues...]: https://github.com/plancomps/CBS-beta/issues "CBS-BETA ISSUE REPORTS ON GITHUB" [Suggest an improvement...]: mailto:plancomps@gmail.com?Subject=CBS-beta%20-%20comment&Body=Re%3A%20CBS-beta%20specification%20at%20Values/Composite/Multisets/Multisets.cbs%0A%0AComment/Query/Issue/Suggestion%3A%0A%0A%0ASignature%3A%0A "GENERATE AN EMAIL TEMPLATE"