Commit 44a8eeda authored by Xavier Thompson's avatar Xavier Thompson

WIP Adapt main.cpp and loop.cpp

parent f08fef65
#include <task.hpp>
#include <root.hpp>
#include <cstdio>
using namespace typon;
task<int> add(int a, int b) {
co_return a + b;
co_return a + b;
}
task<int> loop(int n) {
int result = 0;
for (int i = 0; i < n; i++) {
result = result + co_await add(i, i+1);
}
co_return result;
}
root f() {
int result = co_await loop(100000000);
printf("%d\n", result);
int result = 0;
for (int i = 0; i < n; i++) {
result = result + co_await add(i, i+1);
}
co_return result;
}
int main() {
f();
int result = loop(100000000).call();
printf("%d\n", result);
}
#include <task.hpp>
#include <root.hpp>
#include <cstdio>
......@@ -14,11 +13,7 @@ task<int> fibo(int n) {
co_return a + b;
}
root f() {
int result = co_await fibo(40);
printf("%d\n", result);
}
int main() {
f();
int result = fibo(40).call();
printf("%d\n", result);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment