[Haskell-cafe] Re: Laziness enhances composability: an example

Gleb Alexeyev gleb.alexeev at gmail.com
Fri Jul 10 07:46:13 EDT 2009


Marcin Kosiba wrote:
> Hi,
> 	To illustrate what I meant I'm attaching two examples. In example_1.py I've 
> written code the way I think would be elegant (but it doesn't work). In 
> example_2.py I've written code so that it works, but it isn't elegant.
> 	I know I'm abusing Python iterators here. Also, I'm not sure the way to 
> compose iterators shown in example_2.py is the only option. Actually I'd love 
> to see a better solution, because it would remove a lot of bloat from my 
> code ;)
> 

You may want to look at Lua coroutines, which are more powerful than 
Python iterators. Your example_1.py is very similiar to the example in 
the Coroutines Tutorial [1].

[1] http://lua-users.org/wiki/CoroutinesTutorial



More information about the Haskell-Cafe mailing list