Streams - endless arrays
This commit is contained in:
13
streams-endless-arrays/streams-endless-arrays.js
Normal file
13
streams-endless-arrays/streams-endless-arrays.js
Normal 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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user