# $$\text{Count}$$¶

You can use the $$\text{Count}$$ function to count the number of values of basic types. Values can be provided as parameters or contained within a collection of iterable types.

You can supply a list containing single values, sets, tuples, and matrices. If the supplied sets and tuples contain other sets and tuples, then this function will recursively count basic types within those embedded iterable values.

You can use the \count backslash command to insert this function.

The following variants of this function are available:

• $$\text{integer } \text{Count} \left ( \ldots \right )$$

Note that, while this function works for all data types and works in combination, the functions $$\text{NumberRows}$$, $$\text{NumberColumns}$$, and $$\text{SizeOf}$$ method are more efficient for many scenarios.

Below is a basic example using the $$Count$$ function.

$c = \text{Count } \left ( 1, 2, 3 \right )$
$\text{c = 3}$

The example below shows how you can determine the count across sets and tuples.

$t = \left ( 1, 2, 3 \right )$
$s = \left \lbrace 3, 4, 5 \right \rbrace$
$c = \text{Count} \left ( s, t \right )$
$\text{c = 6}$

You can also find the count through more complex constructs.

$t _ 1 = \left ( 1, 2, 3 \right )$
$s _ 1 = \left \lbrace 3, 4, 5 \right \rbrace$
$t _ 2 = \left ( t _ 1, s _ 1 \right )$
$s _ 2 = \left \lbrace 5, 6 \right \rbrace$
$c = \text{Count} \left ( s _ 2. t _ 2 \right )$
$\text{c = 8}$