# List -- the class of all lists -- {...}

## Description

Lists in Macaulay2 consist of elements of any type, enclosed in braces, and separated by commas.
 i1 : L = {a,1,b,2} o1 = {a, 1, b, 2} o1 : List
The length of a list has two notations, the version with the # is faster when writing programs.
 i2 : #L, length L o2 = (4, 4) o2 : Sequence
The first entry of the list has index 0. Indexing is performed using #.
 i3 : L#2 o3 = b o3 : Symbol

Lists in Macaulay2 are immutable. See MutableList for making and using lists that you may modify.

To convert lists to and from other types of BasicList, in addition to toList, one may use new.

 i4 : new Array from {a,b,c} o4 = [a, b, c] o4 : Array i5 : new List from [a,b,c] o5 = {a, b, c} o5 : List

For an overview of lists and sequences, see lists and sequences.

## Types of list :

• Hybrid -- the class of lists encapsulating hybrid strategies
• VerticalList -- a type of visible self-initializing list that prints vertically

## Functions and methods returning a list :

• "Thing * List" -- see * -- a binary operator, usually used for multiplication
• - List -- negation of a vector
• apply(ZZ,Function) -- apply a function to {0,..., n-1}
• "ascii(String)" -- see ascii -- ASCII character conversion
• associatedPrimes -- find associated primes
• "associatedPrimes(Ideal)" -- see associatedPrimes -- find associated primes
• "associatedPrimes(Module)" -- see associatedPrimes -- find associated primes
• "associatedPrimes(Ring)" -- see associatedPrimes -- find associated primes
• between(Thing,VisibleList) -- insert something between elements of a list
• commonest -- the most common elements of a list or tally
• compositions -- list the compositions of an integer
• degree(Matrix) (missing documentation)
• eulers -- list the sectional Euler characteristics
• findHeft -- find a heft vector for a list of degrees
• genera -- list of the successive linear sectional arithmetic genera
• "icFracP(Ring)" -- see icFracP -- compute the integral closure in prime characteristic
• /// Function \ Ideal /// -- see Ideal / Function -- apply a function to generators of an ideal
• Ideal / Function -- apply a function to generators of an ideal
• "irreducibleDecomposition(MonomialIdeal)" -- see irreducibleDecomposition -- express a monomial ideal as an intersection of irreducible monomial ideals
• "keys(Database)" -- see keys -- keys used in a hash table, dictionary, or database
• "keys(Dictionary)" -- see keys -- keys used in a hash table, dictionary, or database
• "keys(HashTable)" -- see keys -- keys used in a hash table, dictionary, or database
• "lines(String)" -- see lines -- split a string into lines
• "lines(String,String)" -- see lines -- split a string into lines
• List % Number (missing documentation)
• List % RingElement (missing documentation)
• List ** List -- Cartesian product of two lists
• List + List -- sum of two vectors
• List - List -- difference of two vectors
• List / Thing -- vector division
• List // Number (missing documentation)
• List // RingElement (missing documentation)
• List | List -- join lists, sequences or arrays
• "localDictionaries(Dictionary)" -- see localDictionaries -- get local dictionaries
• "localDictionaries(Function)" -- see localDictionaries -- get local dictionaries
• "localDictionaries(Pseudocode)" -- see localDictionaries -- get local dictionaries
• "localDictionaries(Symbol)" -- see localDictionaries -- get local dictionaries
• "locate(List)" -- see locate -- locate source code
• "mingle(BasicList)" -- see mingle -- mingle elements of several lists
• "decompose(Ideal)" -- see minimalPrimes -- minimal primes of an ideal
• "minimalPrimes(Ideal)" -- see minimalPrimes -- minimal primes of an ideal
• "pack(BasicList,ZZ)" -- see pack -- pack elements of a list or string into several shorter lists or strings
• "pack(String,ZZ)" -- see pack -- pack elements of a list or string into several shorter lists or strings
• "pack(ZZ,BasicList)" -- see pack -- pack elements of a list or string into several shorter lists or strings
• "pack(ZZ,String)" -- see pack -- pack elements of a list or string into several shorter lists or strings
• "pairs(BasicList)" -- see pairs -- list the pairs in a hash table, dictionary, or basic list
• "pairs(Dictionary)" -- see pairs -- list the pairs in a hash table, dictionary, or basic list
• "pairs(HashTable)" -- see pairs -- list the pairs in a hash table, dictionary, or basic list
• "partitions(ZZ)" -- see partitions -- list the partitions of an integer
• "partitions(ZZ,ZZ)" -- see partitions -- list the partitions of an integer
• "permutations(ZZ)" -- see permutations -- produce all permutations of a list
• primaryDecomposition -- irredundant primary decomposition of an ideal
• "primaryDecomposition(Ideal)" -- see primaryDecomposition -- irredundant primary decomposition of an ideal
• primaryDecomposition(Module) -- irredundant primary decomposition of a module
• "primaryDecomposition(Ring)" -- see primaryDecomposition(Module) -- irredundant primary decomposition of a module
• regex -- evaluate a regular expression search
• searchPath(List,String) -- search a path for a file
• "searchPath(String)" -- see searchPath(List,String) -- search a path for a file
• "select(String,String)" -- see select(String,String,String) -- select and reformat substrings matching a regular expression
• select(String,String,String) -- select and reformat substrings matching a regular expression
• select(ZZ,Function) -- select integers
• separate -- split a string into substrings using a regular expression
• "List - Set" -- see Set - Set -- set difference
• "subsets(List)" -- see subsets -- produce the subsets of a set or list
• "subsets(List,ZZ)" -- see subsets -- produce the subsets of a set or list
• "subsets(Sequence,ZZ)" -- see subsets -- produce the subsets of a set or list
• "subsets(Set)" -- see subsets -- produce the subsets of a set or list
• "subsets(Set,ZZ)" -- see subsets -- produce the subsets of a set or list
• "subsets(ZZ)" -- see subsets -- produce the subsets of a set or list
• "subsets(ZZ,ZZ)" -- see subsets -- produce the subsets of a set or list
• "toList(BasicList)" -- see toList -- create a list
• "toList(Set)" -- see toList -- create a list
• "toList(String)" -- see toList -- create a list
• transpose(List) -- transposes a table
• unique -- eliminate duplicates from a list
• "unstack(Net)" -- see unstack -- list the rows of a net
• "values(HashTable)" -- see values -- values in a hash table
• "List / Command" -- see VisibleList / Function -- apply a function to elements of a list
• "List / Function" -- see VisibleList / Function -- apply a function to elements of a list
• "List / RingMap" -- see VisibleList / Function -- apply a function to elements of a list
• /// RingMap \ List /// -- see VisibleList / Function -- apply a function to elements of a list

## Methods that use a list :

• "List ? List" -- see ? -- comparison operator
• "ascii(List)" -- see ascii -- ASCII character conversion
• "basis(InfiniteNumber,List,Ideal)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(InfiniteNumber,List,Matrix)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(InfiniteNumber,List,Module)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(InfiniteNumber,List,Ring)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(List,Ideal)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(List,InfiniteNumber,Ideal)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(List,InfiniteNumber,Matrix)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(List,InfiniteNumber,Module)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(List,InfiniteNumber,Ring)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(List,List,Ideal)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(List,List,Matrix)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(List,List,Module)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(List,List,Ring)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(List,Matrix)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(List,Module)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(List,Ring)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(List,ZZ,Ideal)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(List,ZZ,Ring)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(ZZ,List,Ideal)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "basis(ZZ,List,Ring)" -- see basis -- basis or generating set of all or part of a ring, ideal or module
• "capture(List)" -- see capture -- evaluate Macaulay2 code and capture the output
• chainComplex(List) -- make a chain complex
• "check(List,Package)" -- see check -- perform tests of a package
• "check(List,String)" -- see check -- perform tests of a package
• "code(List)" -- see code -- display source code
• "columnPermute(MutableMatrix,ZZ,List)" -- see columnPermute -- permute some columns
• "commonRing(List)" -- see commonRing -- find smallest containing ring
• "degreesMonoid(List)" -- see degreesMonoid -- get the monoid of degrees
• degreesRing(List) -- the ring of degrees
• "diagonalMatrix(List)" -- see diagonalMatrix(Ring,ZZ,ZZ,List) -- make a diagonal matrix from a list
• "diagonalMatrix(Ring,List)" -- see diagonalMatrix(Ring,ZZ,ZZ,List) -- make a diagonal matrix from a list
• diagonalMatrix(Ring,ZZ,ZZ,List) -- make a diagonal matrix from a list
• "diagonalMatrix(RingFamily,List)" -- see diagonalMatrix(Ring,ZZ,ZZ,List) -- make a diagonal matrix from a list
• "diagonalMatrix(RingFamily,ZZ,ZZ,List)" -- see diagonalMatrix(Ring,ZZ,ZZ,List) -- make a diagonal matrix from a list
• "diagonalMatrix(ZZ,ZZ,List)" -- see diagonalMatrix(Ring,ZZ,ZZ,List) -- make a diagonal matrix from a list
• "directSum(List)" -- see directSum -- direct sum of modules or maps
• "document(List)" -- see document -- create a documentation node
• "makeDocumentTag(List)" -- see DocumentTag -- the class of all document tags
• "drop(BasicList,List)" -- see drop -- drop some elements from a list or sequence.
• dual(MonomialIdeal,List) -- the Alexander dual
• "eliminate(List,Ideal)" -- see eliminate
• "export(List)" -- see export -- export symbols from a package
• "exportFrom(Package,List)" -- see exportFrom -- export symbols from a package's private dictionary
• "exportMutable(List)" -- see exportMutable -- export mutable symbols from a package
• "findFiles(List)" -- see findFiles -- find files recursively
• "findHeft(List)" -- see findHeft -- find a heft vector for a list of degrees
• "findProgram(String,List)" -- see findProgram -- load external program
• "gcd(List)" -- see gcd -- greatest common divisor
• "gcdLLL(List)" -- see gcdLLL -- compute the gcd of integers, and small multipliers
• "hashTable(List)" -- see hashTable -- make a hash table
• "HeaderType List" -- see HeaderType -- a class of lists with abbreviated constructors
• "help(List)" -- see help -- view documentation nodes
• "hilbertFunction(List,CoherentSheaf)" -- see hilbertFunction -- the Hilbert function
• "hilbertFunction(List,Ideal)" -- see hilbertFunction -- the Hilbert function
• "hilbertFunction(List,Module)" -- see hilbertFunction -- the Hilbert function
• "hilbertFunction(List,ProjectiveVariety)" -- see hilbertFunction -- the Hilbert function
• "hilbertFunction(List,Ring)" -- see hilbertFunction -- the Hilbert function
• "homogenize(Matrix,RingElement,List)" -- see homogenize -- homogenize with respect to a variable
• "homogenize(Module,RingElement,List)" -- see homogenize -- homogenize with respect to a variable
• "homogenize(RingElement,RingElement,List)" -- see homogenize -- homogenize with respect to a variable
• "homogenize(Vector,RingElement,List)" -- see homogenize -- homogenize with respect to a variable
• "hooks(List)" -- see hooks -- list hooks attached to a key
• "hypertext(List)" -- see hypertext -- prepare hypertext for display
• ideal(List) -- make an ideal
• "importFrom(Package,List)" -- see importFrom -- import symbols to the current private dictionary
• "importFrom(String,List)" -- see importFrom -- import symbols to the current private dictionary
• "intersect(List)" -- see intersect -- compute an intersection
• intersection(List)
• "lcm(List)" -- see lcm -- least common multiple
• List .. List -- rectangular sequences of consecutive lists and sequences
• List ..< List -- rectangular sequences of consecutive lists and sequences
• List << List -- component-wise comparison of lists
• "listSymbols(List)" -- see listSymbols -- compact display of symbols and their values
• "makePackageIndex(List)" -- see makePackageIndex -- create an index of installed packages
• map(Module,Module,List) -- create a matrix by giving a sparse or dense list of entries
• "map(Module,Module,RingMap,List)" -- see map(Module,Module,RingMap,Matrix) -- homomorphism of modules over different rings
• "map(Module,Nothing,RingMap,List)" -- see map(Module,Module,RingMap,Matrix) -- homomorphism of modules over different rings
• map(Module,Nothing,List) -- create a matrix by giving a doubly nested list of ring elements
• map(Module,ZZ,List) -- create a matrix by giving a sparse or dense list of entries
• map(Ring,Ring,List) -- make a ring map
• "match(List,String)" -- see match -- regular expression matching
• Matrix ^ List -- select rows
• Matrix _ List -- select columns
• matrix(List) -- create a matrix from a doubly-nested list of ring elements or matrices
• matrix(Ring,List) -- create a matrix from a doubly nested list of ring elements or matrices
• "matrix(RingFamily,List)" -- see matrix(Ring,List) -- create a matrix from a doubly nested list of ring elements or matrices
• "memoize(Function,List)" -- see memoize -- record results of function evaluation for future use
• "Module / List" -- see Module / Module -- quotient module
• Module ^ List -- projection onto summand
• "Ideal _ List" -- see Module _ List -- map from free module to some generators
• Module _ List -- map from free module to some generators
• "monoid(List)" -- see monoid -- make or retrieve a monoid
• "monomialIdeal(List)" -- see monomialIdeal(Matrix) -- monomial ideal of lead monomials
• "mutableMatrix(List)" -- see mutableMatrix -- make a mutable matrix
• MutableMatrix ^ List (missing documentation)
• MutableMatrix _ List (missing documentation)
• new HashTable from List -- make a hash table from a list
• new OptionTable from List (missing documentation)
• "norm(List)" -- see norm
• "ofClass(List)" -- see ofClass -- English phrases for types
• "OptionTable ++ List" -- see OptionTable ++ OptionTable -- a binary operator, usually used for direct sum
• "List >> Function" -- see OptionTable >> Function -- attaching options to a function
• "part(List,RingElement)" -- see part -- select terms of a polynomial by degree(s) or weight(s)
• product(List) -- product of elements
• random(List) -- shuffle a list randomly
• "random(List,Ring)" -- see random(Type) -- random element of a type
• "Ring / List" -- see Ring / Ideal -- make a quotient ring
• Ring ^ List -- make a free module
• Ring _ List -- make a monomial from a list of exponents
• Ring List -- make a local polynomial ring
• "rowPermute(MutableMatrix,ZZ,List)" -- see rowPermute -- permute some rows
• "rsort(List)" -- see rsort -- sort a list or matrix in reverse order
• "scanLines(Function,List)" -- see scanLines -- apply a function to each line of a file
• selectVariables(List,PolynomialRing) -- make a subring of a polynomial ring generated by selected variables
• "Set - List" -- see Set - Set -- set difference
• SheafOfRings ^ List -- make a graded free coherent sheaf
• sort(List) -- sort a list
• sort(List,Function) (missing documentation)
• span(List) -- construct smallest interval
• "standardPairs(MonomialIdeal,List)" -- see standardPairs -- find the standard pairs of a monomial ideal
• "submatrixByDegrees(Matrix,List,List)" -- see submatrixByDegrees -- submatrix consisting of rows and columns in an interval or box of degrees
• "substitute(Ideal,List)" -- see substitute -- substituting values for variables
• "substitute(Matrix,List)" -- see substitute -- substituting values for variables
• "substitute(Module,List)" -- see substitute -- substituting values for variables
• "substitute(RingElement,List)" -- see substitute -- substituting values for variables
• "substitute(Vector,List)" -- see substitute -- substituting values for variables
• sum(List) -- sum the elements of a list
• "SYNOPSIS(List)" -- see SYNOPSIS -- a standardized synopsis for use in documentation nodes
• "take(BasicList,List)" -- see take -- Take some elements from a list or sequence.
• "tensor(List)" -- see tensor -- tensor product
• "TEST(List)" -- see TEST -- add a test for a package
• truncate(List,Ideal)
• truncate(List,Matrix)
• truncate(List,Module)
• truncate(List,Ring)
• "undocumented(List)" -- see undocumented -- declare that something need not be documented
• vars(List) -- a sequence of variables
• "vector(List)" -- see vector -- make a vector
• Vector ^ List (missing documentation)
• VisibleList _ List -- get some entries of a list
• "weightRange(List,RingElement)" -- see weightRange -- the pair of lowest and highest weights of the monomials
• "WrapperType List" -- see WrapperType -- a class of lists with abbreviated constructors

## For the programmer

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