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.
> Coming from a strong Python and C# background, I find myself missing
> 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
More information about the erlang-questions