compiler working for some mathematical expressions, function calls and
simple conditionals
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
include print: "lib/io/print.dsa"
|
||||
|
||||
int factorial(int n) {
|
||||
if (n <= 1) {
|
||||
return 1;
|
||||
}
|
||||
return n * factorial(n - 1);
|
||||
}
|
||||
|
||||
int add_(int a, int b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
int greater(int a, int b) {
|
||||
if (a + a > b + b) {
|
||||
return a;
|
||||
} else {
|
||||
return b + a;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
printnum(greater(5, add_(5, 5)));
|
||||
|
||||
printnum(factorial(5));
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user