Skip to content

Instantly share code, notes, and snippets.

@yelouafi
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yelouafi/86fc2f29686ca00d255c to your computer and use it in GitHub Desktop.
Save yelouafi/86fc2f29686ca00d255c to your computer and use it in GitHub Desktop.
// map : (Stream a, a -> b) -> Stream b
Stream.prototype.map = function(f) {
return this.isEmpty || this.isAbort ? this
: this.isCons ? Stream.Cons(f(this.head), this.tail.map(f))
: Stream.Future(
this.promise.then(
s => s.map(f),
err => Stream.Abort(err)))
Stream.seq([1,2,3], 0, 1000).map(x => x+1).log('seq')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment