Source File: ex49a.cpp

#include <fmt/core.h>
#include <string>
#include <vector>
#include <algorithm>
#include <ranges>
#include <iostream>
#include <list>
#include <map>

using std::string;

using Node = std::tuple<int, char, std::string>;

using namespace std::views;

int main() {
  std::vector<Node> nodes{
    {1, 'A', "α"},
    {2, 'B', "β"},
    {3, 'C', "γ"},
    {4, 'D', "δ"},
    {5, 'E', "ε"},
  };

  std::vector<std::string> names {
    "Zed",
    "Frank",
    "Joe",
  };

  for(auto e : nodes | take(2) | elements<1>) {
    fmt::println("{}", e);
  }

  for(auto [i, val] : nodes | elements<1> | enumerate) {
    fmt::println("i={}, val={}", i, val);
  }

  auto just_chars = nodes | elements<2>;

  for(auto [the_char, the_name] : zip(just_chars, names)) {
    fmt::println("char={}, name={}", the_char, the_name);
  }

  auto stringify = [](auto a, auto b) {
    return fmt::format("{}: {}", a, b);
  };

  auto new_list = zip_transform(stringify, just_chars, names);

  for(auto x : new_list) {
    fmt::println("{}", x);
  }
}