Streams - endless arrays

This commit is contained in:
2017-08-16 11:03:14 +02:00
parent 73d989eb24
commit 1fec6f3f23

View File

@@ -0,0 +1,13 @@
var Stream = function(start, output, stepping) {
this.curr = start;
this._get = output;
this._next = stepping;
};
Stream.prototype = {
head: function() {
return this._get(this.curr);
},
tail: function() {
return new Stream(this._next(this.curr), this._get, this._next);
}
};