-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Consider the following example from the documentation
const auto employees_below_40 = ages
.zip(names)
.map<person>([](const auto& pair) {
return person(pair.first, pair.second);
})
.filter([](const auto& person) {
return person.age < 40;
})
.sort([](const auto& person1, const auto& person2) {
return person1.age < person2.age;
});This snippet will iterate the corresponding instance of functional_vector 4 times, once for every call (zip, map, filter and sort). If ages would have been a significantly long vector, then the current implementation is really inefficient.
In such cases it would be really useful if we had lazy variants of these algorithms, such that for the final result only one iteration would be performed. A possible but not definite implementation could look like this
const auto employees_below_40 = ages
.lazy_zip(names) // lazy on the top-level call, which propagates down the chain
.map<person>([](const auto& pair) {
return person(pair.first, pair.second);
})
.filter([](const auto& person) {
return person.age < 40;
})
.sort([](const auto& person1, const auto& person2) {
return person1.age < person2.age;
})
.get_result(); // or .execute();Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request