From b87b67ebbba9a732bd4787a3fdc61e3bd2ee4c69 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Sat, 11 Sep 2021 02:34:09 +0200 Subject: [PATCH] Factorial macro example. --- resources/examples/factorial_macro.c3 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 resources/examples/factorial_macro.c3 diff --git a/resources/examples/factorial_macro.c3 b/resources/examples/factorial_macro.c3 new file mode 100644 index 000000000..60d8d9209 --- /dev/null +++ b/resources/examples/factorial_macro.c3 @@ -0,0 +1,16 @@ +macro int factorial($n) +{ + $if ($n == 0): + return 1; + $else: + return $n * @factorial($n - 1); + $endif; +} + +extern func void printf(char *fmt, ...); + +func void main() +{ + int x = @factorial(12); + printf("12! = %d\n", x); +} \ No newline at end of file