Provides generator-like coroutine operations.
Routines supporting generator-like operations. For more general control operators see the F-operator egg.
Returns a coroutine procedure of ARGS. Use '(resume COROUTINE VALUE0 ...)' within the body to invoke another coroutine.
Defines a procedure, NAME, that, when invoked, returns a coroutine procedure parameterized on 'ARG ...'. The ARGLST, if present, are the coroutine procedure arguments. Otherwise the coroutine procedure parameter is 'X'. Use '(resume COROUTINE VALUE0 ...)' within the body to invoke another coroutine.
Returns a generator. The '(yield VALUE)' procedure is used within the body 'EXPR ...' of the generator to produce a single value.
Returns a generator. The '(yield VALUE0 ...)' procedure is used within the body 'EXPR ...' of the generator to produce a multiple values.
Defines a procedure, NAME, that, when invoked, returns a generator parameterized on 'ARG ...'. The '(yield VALUE)' procedure is used within the body 'EXPR ...' of the generator to produce a single value.
Defines a procedure, NAME, that, when invoked, returns a generator parameterized on 'ARG ...'. The '(yield VALUE0 ...)' procedure is used within the body 'EXPR ...' of the generator to produce a multiple values.
(use generator) (define-generator (list->iterator ls) (for-each yield ls) (yield 'EOL)) (define t (list->iterator '(1 2))) (t) ; => 1 continues at caller (t) ; => 2 continues at caller (t) ; => EOL (define-generator (counter n) (yield n) (counter (add1 n))) (define t (counter 20)) (t) ; => 20 (t) ; => 21 ;... and so on
Copyright (c) 2006, Kon Lovett. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.