

                                                         about-generators
                                                                generator

                        Generators and Gatherers


Generators are generalized input streams in the sense of Smalltalk.  A
generator can produce a potentially unbounded number of elements of any
type.  Individual elements are not computed until requested by NEXT-IN.
When an element is taken from a generator, it is removed by side effect.
Subsequent uses of NEXT-IN obtain later elements.

There is a close relationship between a generator and a series of the
elements it produces.  In particular, any series can be converted into a
generator.  As a result, all the scanner functions used for creating series
can be used to create generators as well.  There is no need to have a
separate set of functions for creating generators.

Gatherers are generalized output streams.  Elements of any type can be
entered into a gatherer using NEXT-OUT.  The gatherer combines the elements
together in time-sequence order into a net result.  This result can be
retrieved using RESULT-OF.

There is a close relationship between a gatherer and a collector function
that combines elements in the same way.  In particular, any one-input
one-output collector can be converted into a gatherer.  As a result, all
the collectors used for computing summary results from series can be used
to create gatherers.  There is no need to have a separate set of functions
for creating gatherers.

                              Generators

GENERATOR SERIES                                                 [Function]

Given a series, GENERATOR returns a generator containing the same elements.


     SEE ALSO
     about-series
     about-generators
     next-in
     gatherer
     next-out

;Copyright 1989 by the Massachusetts Institute of Technology,
;Cambridge, Massachusetts.

;Permission to use, copy, modify, and distribute this software and its
;documentation for any purpose and without fee is hereby granted,
;provided that this copyright and permission notice appear in all
;copies and supporting documentation, and that the name of M.I.T. not
;be used in advertising or publicity pertaining to distribution of the
;software without specific, written prior permission. M.I.T. makes no
;representations about the suitability of this software for any
;purpose.  It is provided "as is" without express or implied warranty.

;    M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
;    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
;    M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
;    ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
;    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
;    ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
;    SOFTWARE.



