Commit e59bbdcb authored by Xavier Thompson's avatar Xavier Thompson

Add Makefile and test programs

parent b85829af
CXX=g++-11
CXXFLAGS=-g -O3 -fwhole-program -flto -Wall -Wextra -Werror -std=c++20 -fcoroutines -I.
LDLIBS=-ljemalloc
#include <task.hpp>
#include <cstdio>
using namespace typon;
task<int> add(int a, int 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;
}
int main() {
int result = loop(100000000).call();
printf("%d\n", result);
}
#include <task.hpp>
#include <cstdio>
using namespace typon;
task<int> fibo(int n) {
if (n < 2) {
co_return n;
}
int a = co_await fibo(n - 1);
int b = co_await fibo(n - 2);
co_return a + b;
}
int main() {
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