Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Yeah, Erlang has no means for lazy evaluation. Commented Feb 4, 2011 at 18:45
  • 1
    @Rafe Sure it does! Just use funs. Commented Feb 5, 2011 at 16:21
  • @Daniel curse my early judgement of the language. I should read further into the tutorial. Commented Feb 6, 2011 at 2:50
  • @DanielYankowsky, How would you implement lazy stream with funs in Erlang? Lets say we need to iterate through all odd numbers in a range [1..100] lazily. Commented May 31, 2013 at 11:11
  • @Sharas the quick answer would be to use a generator function which, given a value in the stream, can produce the next value. So a "lazy list" would be a tuple of {initial value, generator function}. If that's not powerful enough, you could have the generator function instead generate the whole tail of the stream... which (being a stream itself) would be a tuple of {initial value, generator function}. Of course, none of the built-in list functions would work on such streams, so you would need to implement the ones you need. For more info, post a new question to SO... somebody will answer. Commented Jun 3, 2013 at 21:22