Hacker News new | past | comments | ask | show | jobs | submit login

You can create lazy enumerables with linq.js as well.

http://neue.cc/reference.htm

    Enumerable
      .Range(0, 1000000000000)
      .Take(10)
      .ToArray()
Output:

    0,1,2,3,4,5,6,7,8,9



There is also "LINQ for Javascript", which is fully integrated in with JQuery and VS as well. http://linqjs.codeplex.com/

Streams seems to be a proper subset of the things you can do with linqjs. Sometimes MSFT can do cool things too, it just doesn't always get picked up :)


Actually, we're talking about the same project. I linked to its reference page for the examples.


Thank you for mentioning this—I had no idea it existed! Do you use lazy enumerables in your projects?

I can think of a few fun uses (such using them as creative replacements for looping constructs), but I'm struggling to find a problem that is most easily solvable with these.


Yes, I use them liberally in C# projects. In fact, I prefer to use them over the standard looping constructs because of the pipe-like characteristics. It's very useful.


buddydvd, linq looks quite nice. Thanks for mentioning it, I had no idea it existed. I added a link to it at the 'Tribute' section of stream.js in case someone wants to check it out or prefers its syntax instead :)


Does that require the obnoxious 100000000000, or could that be left blank?


It's not required, but you'd have to write your own generator function:

    Enumerable
      .Generate((function() {
        var i = 0;
        return function() {
          return i++;
        };
      })())
      .Take(10)
      .ToArray()
Output:

    0,1,2,3,4,5,6,7,8,9




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: