Function Repository Resource:

# MultisetCardinality

Determine the cardinality for a multiset

Contributed by: Robert B. Nachbar (Wolfram Solutions)
 ResourceFunction["MultisetCardinality"][list] gives the cardinality of the multiset list. ResourceFunction["MultisetCardinality"][assoc] gives the cardinality of the Association multiset assoc, effectively giving the total of the values.

## Details

The cardinality of a set is the number of elements it contains, explicitly accounting for the multiplicity of the elements.
The list need not have the head List.
The values of assoc must be counts—that is, non-negative Integer values.

## Examples

### Basic Examples (1)

Give the cardinality:

 In:= Out= In:= Out= ### Scope (1)

MultisetCardinality works with any head, not just List:

 In:= Out= ### Properties and Relations (2)

Compare to Length:

 In:= Out= In:= Out= Compare to Total:

 In:= Out= In:= Out= Robert Nachbar

## Requirements

Wolfram Language 11.3 (March 2018) or above

## Version History

• 1.0.1 – 11 August 2023
• 1.0.0 – 18 February 2019