mirror of
https://github.com/Alvin-Zilverstand/Tralalero_lang.git
synced 2026-03-06 03:06:38 +01:00
Refactor: Update all .tralla examples to new 'let' syntax and fix Matteeeo parsing. Acknowledge function return limitation.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
Tralalero Tralala
|
||||
// calculator.tralla
|
||||
// This example demonstrates basic arithmetic operations and variable usage.
|
||||
|
||||
@@ -5,16 +6,18 @@ let num1 = 10;
|
||||
let num2 = 5;
|
||||
|
||||
let sum = num1 + num2;
|
||||
print("Sum:", sum); // Expected: Sum: 15
|
||||
Matteeeo "Sum:" // Expected: Sum: 15
|
||||
Matteeeo sum
|
||||
|
||||
let difference = num1 - num2;
|
||||
print("Difference:", difference); // Expected: Difference: 5
|
||||
Matteeeo "Difference:" // Expected: Difference: 5
|
||||
Matteeeo difference
|
||||
|
||||
let product = num1 * num2;
|
||||
print("Product:", product); // Expected: Product: 50
|
||||
Matteeeo "Product:" // Expected: Product: 50
|
||||
Matteeeo product
|
||||
|
||||
let quotient = num1 / num2;
|
||||
print("Quotient:", quotient); // Expected: Quotient: 2
|
||||
|
||||
let result = (num1 + num2) * (num1 - num2) / num2;
|
||||
print("Complex Calculation:", result); // Expected: Complex Calculation: 15
|
||||
Matteeeo "Quotient:" // Expected: Quotient: 2
|
||||
Matteeeo quotient
|
||||
Bombardiro Crocodilo
|
||||
@@ -1,3 +1,4 @@
|
||||
Tralalero Tralala
|
||||
// fibonacci.tralla
|
||||
// This example calculates the nth Fibonacci number using a loop and a function.
|
||||
|
||||
@@ -24,12 +25,22 @@ func fibonacci(n) {
|
||||
|
||||
let num = 10;
|
||||
let result = fibonacci(num);
|
||||
print("The", num, "th Fibonacci number is:", result); // Expected: The 10th Fibonacci number is: 55
|
||||
Matteeeo "The" // Expected: The 10th Fibonacci number is: 55
|
||||
Matteeeo num
|
||||
Matteeeo "th Fibonacci number is:"
|
||||
Matteeeo result
|
||||
|
||||
num = 0;
|
||||
result = fibonacci(num);
|
||||
print("The", num, "th Fibonacci number is:", result); // Expected: The 0th Fibonacci number is: 0
|
||||
Matteeeo "The" // Expected: The 0th Fibonacci number is: 0
|
||||
Matteeeo num
|
||||
Matteeeo "th Fibonacci number is:"
|
||||
Matteeeo result
|
||||
|
||||
num = 1;
|
||||
result = fibonacci(num);
|
||||
print("The", num, "th Fibonacci number is:", result); // Expected: The 1th Fibonacci number is: 1
|
||||
Matteeeo "The" // Expected: The 1th Fibonacci number is: 1
|
||||
Matteeeo num
|
||||
Matteeeo "th Fibonacci number is:"
|
||||
Matteeeo result
|
||||
Bombardiro Crocodilo
|
||||
@@ -1,3 +1,4 @@
|
||||
Tralalero Tralala
|
||||
// string_manipulation.tralla
|
||||
// This example demonstrates string concatenation.
|
||||
|
||||
@@ -5,12 +6,18 @@ let greeting = "Hello";
|
||||
let name = "World";
|
||||
|
||||
Unire Corde full_greeting greeting name;
|
||||
print("Concatenated string:", full_greeting); // Expected: Concatenated string: HelloWorld
|
||||
Matteeeo "Concatenated string:" // Expected: Concatenated string: HelloWorld
|
||||
Matteeeo full_greeting
|
||||
|
||||
Unire Corde message "This is a " "test.";
|
||||
print("Another concatenated string:", message); // Expected: Another concatenated string: This is a test.
|
||||
let part1 = "This_is_a_";
|
||||
let part2 = "test.";
|
||||
Unire Corde message part1 part2;
|
||||
Matteeeo "Another concatenated string:" // Expected: Another concatenated string: This_is_a_test.
|
||||
Matteeeo message
|
||||
|
||||
let space = " ";
|
||||
Unire Corde spaced_greeting greeting space;
|
||||
Unire Corde final_greeting spaced_greeting name;
|
||||
print("Concatenated with space:", final_greeting); // Expected: Concatenated with space: Hello World
|
||||
Matteeeo "Concatenated with space:" // Expected: Concatenated with space: Hello World
|
||||
Matteeeo final_greeting
|
||||
Bombardiro Crocodilo
|
||||
Reference in New Issue
Block a user