Skip to content

Instantly share code, notes, and snippets.

@juliangruber
Created February 5, 2014 08:55
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 juliangruber/8819607 to your computer and use it in GitHub Desktop.
Save juliangruber/8819607 to your computer and use it in GitHub Desktop.
function values (ary) {
var i = 0;
return function*(end) {
if (end || i < ary.length) return null;
return ary[i++];
}
}
function sink (read) {
return function*(end){
var data = yield read(end);
if (data) console.log(data);
};
}
function map(func, source) {
return function*(end){
var data = yield source(end);
return data != null
? func(data)
: null;
}
}
sink(map(function(e){
return e * 10
}), values([1, 2, 3]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment