#include <iostream>
#include <vector>
#include <tuple>
#include <cstdint>
template<class T> using Pair= std::tuple<T, T>;
template<class T> using PType = std::vector<Pair<T>>;
template<class T> using DType = std::vector<T>;
template<class T,class F>
DType<T> overlappingPairsCollect(const DType<T>& D,const F& Fun) {
PType<T> P;
T Head = D.front();
for (std::size_t i = 1; i < D.size(); i++) {
const T& Next = D[i];
P.push_back({ Head,Next });
Head = Next;
}
DType<T> R;
for (auto& o : P) {
R.push_back( Fun(std::get<0>(o), std::get<1>(o)));
}
return R;
}
template<class T,class F>
DType<T> MakeHoge(const DType<T>& D,const F& Fun) {
DType<T> R;
for (std::size_t i = 0; i < D.size()-1; i++) {
R.push_back(Fun(D[i], D[i + 1]));
}
return R;
}
int main() {
DType<std::int64_t> D{ 3,1,4,1,5,9,2,6,5 };
//auto R = overlappingPairsCollect(D, [](auto& A, auto& B) { return B - A; });
auto R = MakeHoge(D, [](auto& A, auto& B) { return B - A; });
for (auto& o : R) {
std::cout << o << ',';
}
std::cout << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8dHVwbGU+CiNpbmNsdWRlIDxjc3RkaW50PgoKdGVtcGxhdGU8Y2xhc3MgVD4gdXNpbmcgUGFpcj0gc3RkOjp0dXBsZTxULCBUPjsKdGVtcGxhdGU8Y2xhc3MgVD4gdXNpbmcgUFR5cGUgPSBzdGQ6OnZlY3RvcjxQYWlyPFQ+PjsKdGVtcGxhdGU8Y2xhc3MgVD4gdXNpbmcgRFR5cGUgPSBzdGQ6OnZlY3RvcjxUPjsKCnRlbXBsYXRlPGNsYXNzIFQsY2xhc3MgRj4KRFR5cGU8VD4gb3ZlcmxhcHBpbmdQYWlyc0NvbGxlY3QoY29uc3QgRFR5cGU8VD4mIEQsY29uc3QgRiYgRnVuKSB7CglQVHlwZTxUPiBQOwoKCVQgSGVhZCA9IEQuZnJvbnQoKTsKCWZvciAoc3RkOjpzaXplX3QgaSA9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