3 ms·
You can create lazy enumerables with linq.js as well. http://neue.cc/reference.htm http://neue.cc/reference.htm Enumerable .Range(0, 1000000000000)
by buddydvd 15y ago
You can create lazy enumerables with linq.js as well.
http://neue.cc/reference.htm http://neue.cc/reference.htm
Enumerable
.Range(0, 1000000000000)
.Take(10)
.ToArray()
Output:
0,1,2,3,4,5,6,7,8,9
- LPCRoy 15y agoThere is also "LINQ for Javascript", which is fully integrated in with JQuery and VS as well. http://linqjs.codeplex.com/ 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 :)
- buddydvd 15y agoActually, we're talking about the same project. I linked to its reference page for the examples.
- artursapek 15y agoDoes that require the obnoxious 100000000000, or could that be left blank?
- buddydvd 15y agoIt'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
- esk 15y agoThank 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.
- buddydvd 15y agoYes, 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.
- dionyziz 15y agobuddydvd, 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 :)
- deleted 15y ago[deleted]