# # 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

• #? -- check existence of value in a list, hash table, database, or string
• BasicList # ZZ -- get value from list, hash table, database, or string
• keys -- keys used in a hash table, dictionary, or database
• pairs -- list the pairs in a hash table, dictionary, or basic list
• values -- values in a hash table
• hash tables
• lists and sequences -- a detailed overview of lists and sequences in Macaulay2

## Ways to use this method:

• # BasicList -- length or cardinality
• "# HashTable"
• "# Set"
• "# String"