Macaulay2 » Documentation
Packages » Macaulay2Doc :: select(Thing,Function)
next | previous | forward | backward | up | index | toc

select(Thing,Function) -- select elements from an object with an iterator

Synopsis

Description

Suppose x is an instance of a class with the iterator method installed, e.g., a string, and suppose iter is the output of iterator x. Then a new Iterator object is returned whose next method returns the next output of next iter for which f next iter is true, unless next iter returns StopIteration, in which case this new iterator does the same.

i1 : selectiter = select("foo", i -> i == "o")

o1 = iterator "foo"

o1 : Iterator
i2 : next selectiter

o2 = o
i3 : next selectiter

o3 = o
i4 : next selectiter

o4 = StopIteration

o4 : Symbol

See also

Ways to use this method: