about summary refs log tree commit diff stats
path: root/js/scripting-lang/tests/repl_demo.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/tests/repl_demo.txt')
-rw-r--r--js/scripting-lang/tests/repl_demo.txt180
1 files changed, 180 insertions, 0 deletions
diff --git a/js/scripting-lang/tests/repl_demo.txt b/js/scripting-lang/tests/repl_demo.txt
new file mode 100644
index 0000000..c96f911
--- /dev/null
+++ b/js/scripting-lang/tests/repl_demo.txt
@@ -0,0 +1,180 @@
+/* REPL Demo - Comprehensive Language Feature Showcase */
+
+/* ===== BASIC OPERATIONS ===== */
+/* Arithmetic and function application */
+x : 5;
+y : 10;
+sum : x + y;
+product : x * y;
+difference : y - x;
+quotient : y / x;
+
+/* Function application and partial application */
+double : multiply 2;
+triple : multiply 3;
+add5 : add 5;
+result1 : double 10;
+result2 : add5 15;
+
+/* ===== TABLE OPERATIONS ===== */
+/* Array-like tables */
+numbers : {1, 2, 3, 4, 5};
+fruits : {"apple", "banana", "cherry", "date"};
+
+/* Key-value tables */
+person : {name: "Alice", age: 30, active: true, skills: {"JavaScript", "Python", "Rust"}};
+config : {debug: true, port: 3000, host: "localhost"};
+
+/* Mixed tables */
+mixed : {1, name: "Bob", 2, active: false, 3, "value"};
+
+/* Table access */
+first_number : numbers[1];
+person_name : person.name;
+mixed_name : mixed.name;
+
+/* ===== FUNCTIONAL PROGRAMMING ===== */
+/* Higher-order functions */
+doubled_numbers : map @double numbers;
+filtered_numbers : filter @(lessThan 3) numbers;
+sum_of_numbers : reduce @add 0 numbers;
+
+/* Function composition */
+compose_example : double via add5 via negate;
+result3 : compose_example 10;
+
+/* Pipeline operations */
+pipeline : numbers via map @double via filter @(greaterThan 5) via reduce @add 0;
+
+/* ===== PATTERN MATCHING ===== */
+/* When expressions */
+grade : 85;
+letter_grade : when grade {
+    >= 90: "A";
+    >= 80: "B";
+    >= 70: "C";
+    >= 60: "D";
+    default: "F";
+};
+
+/* Complex pattern matching */
+status : "active";
+access_level : when status {
+    "admin": "full";
+    "moderator": "limited";
+    "user": "basic";
+    default: "none";
+};
+
+/* ===== ADVANCED COMBINATORS ===== */
+/* Combinator examples */
+numbers2 : {2, 4, 6, 8, 10};
+evens : filter @(equals 0 via modulo 2) numbers2;
+squares : map @(power 2) numbers2;
+sum_squares : reduce @add 0 squares;
+
+/* Function composition with combinators */
+complex_pipeline : numbers via 
+    map @(multiply 2) via 
+    filter @(greaterThan 5) via 
+    map @(power 2) via 
+    reduce @add 0;
+
+/* ===== TABLE ENHANCEMENTS ===== */
+/* Table transformations */
+users : {
+    user1: {name: "Alice", age: 25, role: "admin"},
+    user2: {name: "Bob", age: 30, role: "user"},
+    user3: {name: "Charlie", age: 35, role: "moderator"}
+};
+
+/* Extract specific fields */
+names : map @(constant "name") users;
+ages : map @(constant "age") users;
+
+/* Filter by conditions */
+admins : filter @(equals "admin" via constant "role") users;
+young_users : filter @(lessThan 30 via constant "age") users;
+
+/* ===== REAL-WORLD EXAMPLES ===== */
+/* Data processing pipeline */
+data : {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+processed : data via 
+    filter @(greaterThan 5) via 
+    map @(multiply 3) via 
+    filter @(lessThan 25);
+
+/* Configuration management */
+default_config : {port: 3000, host: "localhost", debug: false};
+user_config : {port: 8080, debug: true};
+merged_config : merge default_config user_config;
+
+/* ===== ERROR HANDLING EXAMPLES ===== */
+/* Safe operations */
+safe_divide : (x, y) => when y {
+    0: "Error: Division by zero";
+    default: x / y;
+};
+
+safe_result1 : safe_divide 10 2;
+safe_result2 : safe_divide 10 0;
+
+/* ===== PERFORMANCE EXAMPLES ===== */
+/* Large dataset processing */
+large_numbers : {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+processed_large : large_numbers via 
+    map @(power 2) via 
+    filter @(greaterThan 50) via 
+    reduce @add 0;
+
+/* ===== DEBUGGING EXAMPLES ===== */
+/* State inspection helpers */
+debug_state : {
+    numbers: numbers,
+    person: person,
+    processed: processed,
+    config: merged_config
+};
+
+/* ===== EXPORT EXAMPLES ===== */
+/* Exportable configurations */
+export_config : {
+    version: "1.0.0",
+    features: {"tables", "functions", "pattern-matching"},
+    examples: {
+        basic: "Basic arithmetic and function application",
+        advanced: "Complex functional pipelines",
+        real_world: "Data processing examples"
+    }
+};
+
+/* ===== COMPREHENSIVE SHOWCASE ===== */
+/* This demonstrates all major language features in one pipeline */
+comprehensive_example : {
+    input: numbers,
+    doubled: map @double numbers,
+    filtered: filter @(greaterThan 3) numbers,
+    composed: double via add5 via negate,
+    pattern_matched: when (length numbers) {
+        > 5: "Large dataset";
+        > 3: "Medium dataset";
+        default: "Small dataset";
+    },
+    final_result: numbers via 
+        map @(multiply 2) via 
+        filter @(greaterThan 5) via 
+        reduce @add 0
+};
+
+/* Output results for verification */
+..out "REPL Demo completed successfully!";
+..out "All language features demonstrated:";
+..out "  ✓ Basic operations and arithmetic";
+..out "  ✓ Table literals and access";
+..out "  ✓ Function application and composition";
+..out "  ✓ Pattern matching with when expressions";
+..out "  ✓ Higher-order functions and combinators";
+..out "  ✓ Table transformations and pipelines";
+..out "  ✓ Real-world data processing examples";
+..out "  ✓ Error handling and safe operations";
+..out "  ✓ Performance and debugging features"; 
\ No newline at end of file
'>^
2199940a ^
82ac0b7e ^
2caaa7f1 ^


82ac0b7e ^
2caaa7f1 ^
b2e4056d ^
82ac0b7e ^

363be37f ^
795f5244 ^
6c96a437 ^
795f5244 ^
82ac0b7e ^
6c96a437 ^
ab6ed192 ^
0487a30e ^
aae198a9 ^
0f2781f8 ^
82ac0b7e ^

ae256ea1 ^

9dcbec39 ^
35064671 ^

af023b32 ^
ae256ea1 ^
3e5f4358 ^
9dcbec39 ^
3e5f4358 ^

f3760b0f ^
f22250a1 ^
9dcbec39 ^
82ac0b7e ^

795f5244 ^
57d01f21 ^
9dcbec39 ^
57d01f21 ^

f22250a1 ^
82ac0b7e ^



82ac0b7e ^


b24eb476 ^

82ac0b7e ^
1b76245c ^
82ac0b7e ^

ae256ea1 ^
af023b32 ^
b24eb476 ^
82ac0b7e ^
363be37f ^
1e38eee5 ^
363be37f ^

82ac0b7e ^




b24eb476 ^
82ac0b7e ^
f3760b0f ^
9dcbec39 ^
6c96a437 ^
1b76245c ^
82ac0b7e ^
1b76245c ^
1e38eee5 ^
82ac0b7e ^







b24eb476 ^
82ac0b7e ^
f3760b0f ^
9dcbec39 ^
1e38eee5 ^
82ac0b7e ^
f22250a1 ^

82ac0b7e ^

5f98a10c ^
b24eb476 ^

82ac0b7e ^
ae256ea1 ^
af023b32 ^
9dcbec39 ^
e4630643 ^

ae256ea1 ^
82ac0b7e ^
f3760b0f ^
82ac0b7e ^
1e38eee5 ^


1ead3562 ^
1e38eee5 ^
192d59d3 ^
1e38eee5 ^
9dcbec39 ^

2655ae72 ^



514f0e34 ^
760f683f ^

897ae8c1 ^
2655ae72 ^


aae198a9 ^
897ae8c1 ^
760f683f ^
2655ae72 ^

897ae8c1 ^
23d3a022 ^
2655ae72 ^
23d3a022 ^
b0631dec ^




a519b78c ^
b0631dec ^






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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185