Gets the next value from an iterator.
The iterator whose next value is to be retrieved.
Certain functions return iterators rather than returning a list of all values. This is because the list may be large and/or expensive
to generate in its entirety, while generating just the next value is not expensive. The
nextElem function returns just the next value
or raises an exception if there are no more values to return. The related function
as.list will retrieve all the values
from the iterator and return them as a list.
The next value from the iterator or an exception if there are no more values.