Skip to content

Commit

Permalink
* Adds squares example
Browse files Browse the repository at this point in the history
  • Loading branch information
njlr committed Oct 31, 2018
1 parent 6e4cf26 commit 953e292
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/squares/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cxx_binary(
name = 'squares',
srcs = [
'main.cpp',
],
compiler_flags = [
'-fPIC',
'-pthread',
],
linker_flags = [
'-pthread',
],
deps = [
'//:conduit',
],
)
23 changes: 23 additions & 0 deletions examples/squares/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <iostream>
#include <conduit/conduit.hpp>

using namespace conduit;
using namespace operators;

auto squares = []() -> seq<int> {
int x = 0;

while ( true ) {
co_yield x * x;

++x;
}
};

int main() {
for (auto x : squares() >> take(10)) {
std::cout << x << std::endl;
}

return 0;
}

0 comments on commit 953e292

Please sign in to comment.