next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc > The Macaulay2 language > operators > #

# -- length or access to elements

Description

# is used as both a unary and a binary operator.

As a unary operator: #x returns the length or cardinality of a list, set, hash table, or string x.

As a binary operator: x#i returns the ith element of a list, hash table, database, or string x.

i1 : L = {23, 42, 107, 2, 50};
i2 : #L

o2 = 5
i3 : L#2

o3 = 107

Caveat

The precedence of # when used as a binary operator is high, as high as ., but when used as a unary operator the precedence is much lower.

See also

Ways to use # :

For the programmer

The object # is a keyword.