Skip to content

Instantly share code, notes, and snippets.

@wilhelmjung
Created November 1, 2013 07:36
Show Gist options
  • Select an option

  • Save wilhelmjung/7262023 to your computer and use it in GitHub Desktop.

Select an option

Save wilhelmjung/7262023 to your computer and use it in GitHub Desktop.
// compile with: /EHsc
#include <windows.h>
#include <ppl.h>
#include <concurrent_vector.h>
#include <array>
#include <vector>
#include <tuple>
#include <algorithm>
#include <iostream>
#include <cstdlib> // rand()
//using namespace concurrency; // ns for ppl
using namespace std;
struct my_ftor {
void operator() (double d)
{
cout << d << " ";
}
} printer;
int main()
{
array<double, 10> seq;
generate(begin(seq), end(seq), []
{
return (double)rand() / (double)RAND_MAX;
});
for_each(begin(seq), end(seq), [] (double &item)
{
item = sin(item);
});
cout << "seq: ";
for_each(begin(seq), end(seq), printer);
cout << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment