Ducklang/example.duck

31 lines
452 B
Plaintext

/*
An example of program with most of
the supported features
*/
x = true;
z = 3 + 4 * (2 + 1); // good order of op
if (x) {
y = 5;
while (x) {
print y;
if (!y && z % 2) {
break;
} else if (y == 3) { // never reached because of continue
z = 5;
} else if (y == 4) {
y = y - 2;
continue;
}
y = y - 1;
}
} else {
// never reached
y = -8;
x = true;
}
fn hello(name) {
return "Hello, " + name + '!';
}
print hello("flavien");