# # BasicList -- length or cardinality

## Synopsis

• Operator: #
• Usage:
#x
• Inputs:
• x, , HashTable, Set, or String
• Outputs:

## Description

If x is a list, #x is the number of elements in x.

 i1 : L = {1, 2, 3, 2, 1}; i2 : #L o2 = 5

If x is a set, #x is the cardinality of x.

 i3 : S = new Set from L o3 = set {1, 2, 3} o3 : Set i4 : #S o4 = 3

If x is a hash table, #x is the number of key-value pairs stored in x.

 i5 : T = new HashTable from {a => 1, b => 2} o5 = HashTable{a => 1} b => 2 o5 : HashTable i6 : #T o6 = 2

If x is a string, #x is the number of characters in x.

 i7 : s = "a perfectly adequate example of a string"; i8 : #s o8 = 40