ES6-like iterators and functional programming