alpaqa 1.0.0a9
Nonconvex constrained optimization
Loading...
Searching...
No Matches
util.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <iterator>
4#include <numeric>
5#include <string>
6
8 const auto &container,
9 const auto &proj = [](const auto &x) -> decltype(auto) { return x; }) {
10 if (container.empty())
11 return std::string{};
12 auto penult = std::prev(container.end());
13 auto quote_concat = [&](std::string &&a, const auto &b) {
14 return a + "'" + std::string(proj(b)) + "', ";
15 };
16 return std::accumulate(container.begin(), penult, std::string{},
17 quote_concat) +
18 "'" + std::string(proj(*penult)) + "'";
19}
std::string format_string_list(const auto &container, const auto &proj=[](const auto &x) -> decltype(auto) { return x;})
Definition: util.hpp:7