NabeelScript Examples
Basic Arithmetic and String Operations
x = 10;
y = 20;
print(x + y); // Outputs: 30
text = "Hello, " + "World!";
print(text); // Outputs: Hello, World!
Using String Functions
text = " Hello, World! ";
print(length(text)); // Outputs: 16
print(uppercase(text)); // Outputs: " HELLO, WORLD! "
print(lowercase(text)); // Outputs: " hello, world! "
print(trim(text)); // Outputs: "Hello, World!"
print(replace(text, "World", "NabeelScript")); // Outputs: " Hello, NabeelScript! "
Working with Arrays
arr = [1, 2, 3, 4, 5];
print(arr); // Outputs: [1, 2, 3, 4, 5]
arr = push(arr, 6);
print(arr); // Outputs: [1, 2, 3, 4, 5, 6]
popped = pop(arr);
print(popped); // Outputs: 6
print(arr); // Outputs: [1, 2, 3, 4, 5]
print(length(arr)); // Outputs: 5
print(first(arr)); // Outputs: 1
print(last(arr)); // Outputs: 5
Control Structures
x = 15;
if x > 15 {
print("x is greater than 15");
} elseif x > 5 {
print("x is greater than 5 but not greater than 15");
} else {
print("x is 5 or less");
}
i = 0;
while i < 5 {
print(i);
i = i + 1;
}
for (i = 0; i < 5; i = i + 1) {
print(i);
}
File Operations
content = read_file("input.txt");
print(content);
write_file("output.txt", "Hello, NabeelScript!");