JavaScript library (stream.js) introduces a "new" numerical data structure: streams. This container is similar to an array and a linked list, but it contains an unlimited number of elements that are realized by a lazy evaluation.


var s = Stream.range (10, 20);
s.print (); // prints the numbers from 10 to 20

You can specify only the beginning of the range Stream.range (low) for an argument Stream.range (low, high), then the stream will consist of an unlimited natural numbers. Stream.range () starts with 1 by a default.

The idea of supposedly "infinite" range simplifies the programming. For example, in this way, a list of odd and even numbers is produced.
BumBum 29 october 2011, 19:32