Skip to content

Instantly share code, notes, and snippets.

@fabiogaluppo
Last active December 7, 2015 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiogaluppo/3c3f0bcc5ba2697763fe to your computer and use it in GitHub Desktop.
Save fabiogaluppo/3c3f0bcc5ba2697763fe to your computer and use it in GitHub Desktop.
std::array<int, 10> zs;
fill_ap(zs.begin(), zs.end(), 2, 3);
display(zs); //2 5 8 11 14 17 20 23 26 29
initial = 0;
total = std::accumulate(zs.rbegin(), zs.rend(), initial); //accumulate is fold
std::cout << total << "\n"; //155
std::vector<int> ws;
unfold_ap(total, 2, 3, std::back_inserter(ws));
display(ws); //2 5 8 11 14 17 20 23 26 29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment