lazy.js
lazy.js copied to clipboard
zip infinite sequence and infinite sequence bug?
http://jsfiddle.net/XVyTJ/
node
var _ = require('lazy.js');
var natural = function(n)
{
return n;
};
var _natural = _.generate(natural); //0 1 2 3 4 5 .....
var _even = _natural
.zip(_natural);
// .map(add); //0 2 4 6 8 10 .....
var even10 =
_even
.take(10)
.toArray();
console.log(even10);
result
[ [ 0, undefined ],
[ 1, undefined ],
[ 2, undefined ],
[ 3, undefined ],
[ 4, undefined ],
[ 5, undefined ],
[ 6, undefined ],
[ 7, undefined ],
[ 8, undefined ],
[ 9, undefined ] ]
Is this a bug or I do something wrong?
From the API documentation, zip requires an array as argument. Do you think it should work with sequences too? Then this should be a feature request ;)
Yeah, zipping together two sequences would be very nice. I'd suggest we change this to be a feature request.