public IteratorResult fold (IteratorFoldFunction func, Value ret)

Folds func over the elements of iter.

That is to say, func will be called as func (object, ret, user_data) for each object in this. The normal use of this procedure is to accumulate the results of operating on the objects in ret .

This procedure can be used (and is used internally) to implement the @foreach and find_custom operations.

The fold will proceed as long as func returns true. When the iterator has no more arguments, DONE will be returned. If func returns false , the fold will stop, and OK will be returned. Errors or resyncs will cause fold to return ERROR or RESYNC as appropriate.

The iterator will not be freed.



The Iterator to fold over


the fold function


the seed value passed to the fold function


user data passed to the fold function