// Operations
print(1 + 2);
print(2 - 1);
print(2 * 2);
print(2 / 2);
// Comparison
print(2 == 2);
print(2 != 1);
print(2 > 1);
print(1 < 2);
print(2 >= 2);
print(2 =< 2);
// Strings
print("Hiya!");
print("Hello, " + "world!");
// Booleans
print(true or false);
print(true and false);
// Null values
nil
// Variables
var a = 0;
print(a);
a = a + 1;
print(a);
// Conditionals
if (2 > 1) {
print("The universe still works!");
} else {
print("oh what")
}
// Looping
var i = 0;
while (i < 100) {
print(i);
i = i + 1;
}
for(var i = 0; i < 100; i = i + 1;) {
print(i);
}
// Functions
fun plus_one(i) {
return i + 1;
}
print(plus_one(1));
// Note: Functions are like variables, witch means you can pass them to other functions. You cant do this though: function(fun (i) { return i + 1; })
-
Notifications
You must be signed in to change notification settings - Fork 1
a lox interpreter
License
kore-signet/lax
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|