Macaulay2 » Documentation
Packages » Macaulay2Doc :: Option
next | previous | forward | backward | up | index | toc

Option -- the class of all key-value pairs K => V

Description

Such pairs are used as optional arguments for functions.

i1 : o = Limit => 5

o1 = Limit => 5

o1 : Option
i2 : peek o

o2 = Option{Limit, 5}

There is also a way to make new hash tables from lists of key-value pairs.

i3 : ht = new HashTable from {a => 5, b => 7}

o3 = HashTable{a => 5}
               b => 7

o3 : HashTable
i4 : keys ht

o4 = {a, b}

o4 : List
i5 : values ht

o5 = {5, 7}

o5 : List
i6 : pairs ht

o6 = {(a, 5), (b, 7)}

o6 : List

These pairs are implemented as lists, so that if z is x => y, then x is z#0 and y is z#1.

i7 : o#0

o7 = Limit

o7 : Symbol
i8 : o#1

o8 = 5

See also

Functions and methods returning an option :

Methods that use an option :

For the programmer

The object Option is a type, with ancestor classes BasicList < Thing.