-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.linguo
More file actions
90 lines (74 loc) · 2.03 KB
/
test.linguo
File metadata and controls
90 lines (74 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// test.linguo - Comprehensive demonstration of Linguo language features
// This file showcases the natural English-like syntax and core capabilities of Linguo
// ===== Basic Variable Declaration and Output =====
remember greeting as "Welcome to Linguo!"
say greeting
// ===== Data Types and Operations =====
// Numbers
remember x as 42
remember y as 8
// Basic arithmetic
increase x by y // Addition: x = x + y
decrease x by 2 // Subtraction: x = x - 2
multiply x by 2 // Multiplication: x = x * 2
divide x by 4 // Division: x = x / 4
say "Result of arithmetic operations: " + x
// Booleans
remember isTrue as true
remember isFalse as false
say "Boolean value: " + isTrue
// ===== Control Flow =====
// Conditional execution
when x is more than 20
say "x is greater than 20"
or
say "x is not greater than 20"
done
// Loop demonstration
remember counter as 0
do this 3 times
increase counter by 1
say "Loop iteration: " + counter
done
// ===== Functions =====
// Simple function without parameters
create greet
say "Hello from Linguo!"
end
// Function with parameters
create add a b
remember result as a
increase result by b
give back result
end
// Function with multiple parameters and complex logic
create calculateAverage x y z
remember sum as x
increase sum by y
increase sum by z
remember average as sum
divide average by 3
give back average
end
// ===== Program Execution =====
say "Calling functions:"
call greet
remember num1 as 10
remember num2 as 20
remember sum as call add with num1, num2
say "Sum of " + num1 + " and " + num2 + " is: " + sum
remember avg as call calculateAverage with 15, 25, 35
say "Average of 15, 25, and 35 is: " + avg
// ===== Complex Example: Fibonacci Sequence =====
say "Generating Fibonacci sequence:"
remember fib1 as 0
remember fib2 as 1
say fib1 // First number
say fib2 // Second number
do this 5 times
remember temp as fib2
increase fib2 by fib1
remember fib1 as temp
say fib2
done
say "Program execution completed."