[erlang-questions] generators/iterators

Damien Morton dmorton@REDACTED
Mon Jun 18 00:23:20 CEST 2007

Umm, I just realised that a stream/generator would need to be a function 
that returns a function that can be called repeatedly to generate the 
sequence, probably terminating with a well-known sequence terminating 

This would solve the problem of the generators needing to be reset 
during nested loops in a comprehension.

> Hmm,
> Coming from a strong Python and C# background, I find myself missing 
> generators/iterators.
> For example, when using list comprehension syntax, I find myself wanting 
> to use a function as a generator
> items(X) ->
>     fun() -> next_item(X) end.
> [Y*Y || Y <- items(X)]
> Would it be simple to have erlang recognise a function as a generator?
> Sorry if the terminology is getting mixed up here.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list