This is the homepage of TRIQS/itertools 1.3.0. The source code can be found on GitHub.
#include <vector>
using namespace itertools;
int main() {
for(
int i:
range(10)) { }
for(
int i:
range(2, 10, 2)) { }
}
std::vector<char> Vc{'a', 'b', 'c'};
}
std::vector<double> Vd{2.0, 4.0, 1.0};
for (
auto [c, d] :
zip(Vc, Vd)) {
}
for (
auto [c, d] :
product(Vc, Vd)) {
}
for (
auto x :
transform(Vd, [](
auto d){
return d * d; })) {
}
}
auto product_range(Is... is)
Create a cartesian product range of integer ranges from given integers.
auto transform(R &&rg, F lambda)
Lazy-transform a given range by applying a unary callable object to every element of the original ran...
itertools::multiplied< Rs... > product(Rs &&...rgs)
Lazy-multiply a given number of ranges by forming their cartesian product.
zipped< Rs... > zip(Rs &&...rgs)
Lazy-zip ranges together (similar to Python's zip).
enumerated< R > enumerate(R &&rg)
Lazy-enumerate a given range (similar to Python's enumerate).
itertools defines a small subset of the ranges and views from std::ranges. The main purpose of the library is to provide lazy ranges
- that can be iterated over in range-based for loops (see example above) and
- that can be used to make lazy views of multidimensional arrays
#include <nda/nda.hpp>
int main() {
auto A = nda::matrix<int>::rand(10, 10);
auto sub_A = A(nda::range(0, 10, 2), nda::range::all);
}
Visit TRIQS/nda for more details.
Note that nearly all of the functionality (and much more) of itertools is also provided by std::ranges or Eric Niebler's range-v3 library. We therefore recommend to use one of those, if you have a choice.
Where to start?
The Installation section tells you how to get the library and make it available on your system.
Integration in C++ projects explains how to integrate itertools in your own C++ code.
Then, you can start with the Examples section to get an overview of the library's features and how it compares with std::ranges
.
Furthermore, we provide a detailed reference API Documentation to answer your questions.
If you experience any problem with the library, you can post an Issue on GitHub.