Repository navigation
Expand file tree
/
Copy pathHelp_EN.txt
More file actions
3033 lines (2707 loc) · 78.5 KB
/
Copy pathHelp_EN.txt
File metadata and controls
3033 lines (2707 loc) · 78.5 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
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
================================================================
ARRAYVATOR — A DATA PROCESSING LANGUAGE
================================================================
WHAT IT IS
----------------------------------------------------------------
ArrayVator is a programming language for processing tabular
data. It was built for analysts, economists, marketers,
accountants, researchers, and everyone who works with tables:
Excel, CSV, Parquet, SQLite databases.
Instead of complex code and dozens of libraries — a single,
readable language where every operation reads like an
ordinary sentence:
m = filterif(m[:, "Department"] == "IT")
m = sort(m[:, "Salary"], ZA)
m = addcolumn(m, "Tax", m[:, "Salary"] * 0.13)
This is not Python. Not R. Not SQL. This is a separate language
purpose-built so that a person without a programming background
can learn it in a single evening.
----------------------------------------------------------------
WHY IT EXISTS
----------------------------------------------------------------
• Process tables without Excel and without VBA.
• Do data analysis without Python and without pandas.
• Build pivot tables without Excel's pivot tables.
• Build charts without matplotlib.
• Produce reports without Word and without layout tools.
• Compile a finished program into a .exe and hand it to a
colleague with no installation required.
One file with code — and the entire analysis logic is in your
hands. No dependencies, no version conflicts.
----------------------------------------------------------------
WHAT IS BUILT INTO THE LANGUAGE
----------------------------------------------------------------
More than 300 functions. Everything an analyst needs —
out of the box:
• Filtering, sorting, removing duplicates.
• Grouping, aggregation, pivot / unpivot tables.
• Conditional aggregates: sumif, countif, avgif, minif, maxif.
• Window functions: rownumber, rank, lag, lead, winsum.
• ABC analysis, Pareto analysis, anomaly detection
(iqr, zscore, percentile).
• Dates: year, month, day, adddays, datetrunc, calendar.
• Text: trim, clean, split, replacetext, deletetext.
• None handling: isnone, fillna, dropna, coalesce, noneif.
• SQL-like operations: join, groupby, having.
• Files: Excel, CSV, TXT, Parquet, SQLite.
• BigData mode on DuckDB: up to a billion rows, ~50 MB RAM.
• Charts: bar, line, pie, hist, scatter, box, heatmap, pair.
• HTML reports with interactive Plotly charts.
• Matrix ↔ DuckDB conversion in a single line.
----------------------------------------------------------------
THE MAIN IDEA — READABILITY
----------------------------------------------------------------
ArrayVator is built on a simple principle: code should be
understandable by a human, not only by a machine.
m = deleteif(m[:, "Department"] == "IT")
Reads in plain English: "delete rows where Department equals IT".
No braces, no indices, no commas — just a phrase.
Function names are short, meaningful, in English:
filterif, sort, groupby, sumif, vlookup, transpose.
You don't have to memorize them — the editor suggests them.
----------------------------------------------------------------
SMART AUTOCOMPLETE
----------------------------------------------------------------
The editor understands what you're typing and suggests.
Start typing "fil" — the editor suggests filterif.
Type "впр" (Russian alias for VLOOKUP) — the editor suggests vlookup.
Type "суммапо" — the editor suggests sumif.
Autocomplete works:
• by partial function name (fil → filterif);
• by Russian aliases (впр → vlookup, сводная → pivot);
• by the first letter;
• with arrow-key navigation ↑ ↓;
• with insertion via Tab or Enter.
The candidate list appears right under the cursor — just like
in modern IDEs. Nothing has to be memorized.
----------------------------------------------------------------
LIVE HELP WITH EXAMPLES
----------------------------------------------------------------
On the right side of the editor — a live help panel.
Click a function name in your code and you'll see:
• SYNTAX — the exact call format.
• DESCRIPTION — what the function does.
• EXAMPLE — how to call it.
• MATRIX EXAMPLE — concrete input, code and output.
Help updates instantly on click. No switching windows,
no Googling. Everything — right next to your code.
If a function doesn't exist — the editor suggests similar
ones and hints at what you might have meant.
----------------------------------------------------------------
POWERFUL ERROR HANDLING WITH HINTS
----------------------------------------------------------------
Errors in ArrayVator are not dry messages — they are full
explanations. Every error includes:
• What's wrong (in plain language).
• Where exactly (line and column, with a ^ pointer).
• How to fix it (a concrete example of correct code).
• Why it's this way (an explanation of the language's logic).
Example error message:
❌ Error (line 3):
if x = 5 then
In the condition '=' (assignment) is used,
but '==' (comparison) is required.
Incorrect: if x = 5 then
Correct: if x == 5 then
💡 '=' — assigns a value.
'==' — compares values.
Plus — automatic hints:
• "Did you mean filterif?"
• "Missing closing parenthesis ')' — add it at the end."
• "The keyword 'then' is required after the if condition."
Errors are available in two languages — Russian and English —
switchable with a single setting.
----------------------------------------------------------------
BUILD .EXE IN TWO CLICKS
----------------------------------------------------------------
The signature feature of ArrayVator: you can turn your script
into a standalone .exe program and hand it to a colleague —
no Python install, no library install, no configuration.
How it works:
1. Write code in the ArrayVator editor.
2. Click "Export to EXE".
3. Set the program name — for example, MyReport.exe.
4. Get a folder with the .exe and all libraries.
Your colleague double-clicks the .exe — and it just works.
No installs. No dependencies. Just a file.
The compiler picks the right runner automatically:
• If the code only has tables and math — a compact MINIMAL
runner is built.
• If Excel or DuckDB is used — a DATA runner is built.
• If charts or reports are used — a FULL runner is built.
You don't have to think about this — the compiler chooses.
----------------------------------------------------------------
WHAT THE EDITOR DOES
----------------------------------------------------------------
ArrayVator Editor is a full development environment:
• Syntax highlighting (keywords, functions, variables,
strings, numbers, comments — each in its own color).
• Line numbers.
• Find and replace (case-sensitive and case-insensitive).
• Built-in output console.
• Working folder — next to the editor.
• Auto-save of settings.
• Dark and light themes.
• Russian and English interface.
• Configurable fonts and highlight palette.
• Help panel that updates on click.
• Autocomplete with aliases.
• Error handling with human-readable hints.
All of this — in a single window. No external dependencies.
----------------------------------------------------------------
WHO THIS LANGUAGE IS FOR
----------------------------------------------------------------
• Analyst — quickly count, group, plot.
• Economist — build summaries by department and quarter.
• Marketer — run ABC analysis and find anomalies.
• Accountant — process exports from Excel or accounting systems.
• Researcher — clean data and compute statistics.
• Student — learn tabular work without Python.
• Manager — produce a report and pass it to colleagues.
ArrayVator is a language for people who work with data
but don't want to spend months learning Python and pandas.
----------------------------------------------------------------
WHAT THE LANGUAGE DOESN'T HAVE (AND NEVER WILL)
----------------------------------------------------------------
• Classes, inheritance, OOP.
• Lambdas and functional programming.
• Imports and package installs.
• Dependencies on external libraries (except BigData mode).
• Complex syntax for the sake of syntax.
The language is deliberately simple. Everything an analyst
doesn't need — has been removed.
----------------------------------------------------------------
SUMMARY
----------------------------------------------------------------
ArrayVator is:
✔ One readable language instead of ten libraries.
✔ 300+ built-in functions for data analysis.
✔ Smart autocomplete, including Russian aliases.
✔ Live help with examples right in the editor.
✔ Clear errors with hints and code examples.
✔ Build .exe in two clicks.
✔ Work with a billion rows via DuckDB.
✔ Charts and HTML reports out of the box.
✔ No dependencies when passing code to colleagues.
Simple. Readable. Fast. Yours.
================================================================================================================================
ARRAYVATOR — A DATA PROCESSING LANGUAGE
================================================================
WHAT IT IS
----------------------------------------------------------------
ArrayVator is a programming language for processing tabular
data. It was built for analysts, economists, marketers,
accountants, researchers, and everyone who works with tables:
Excel, CSV, Parquet, SQLite databases.
Instead of complex code and dozens of libraries — a single,
readable language where every operation reads like an
ordinary sentence:
m = filterif(m[:, "Department"] == "IT")
m = sort(m[:, "Salary"], ZA)
m = addcolumn(m, "Tax", m[:, "Salary"] * 0.13)
This is not Python. Not R. Not SQL. This is a separate language
purpose-built so that a person without a programming background
can learn it in a single evening.
----------------------------------------------------------------
WHY IT EXISTS
----------------------------------------------------------------
• Process tables without Excel and without VBA.
• Do data analysis without Python and without pandas.
• Build pivot tables without Excel's pivot tables.
• Build charts without matplotlib.
• Produce reports without Word and without layout tools.
• Compile a finished program into a .exe and hand it to a
colleague with no installation required.
One file with code — and the entire analysis logic is in your
hands. No dependencies, no version conflicts.
----------------------------------------------------------------
WHAT IS BUILT INTO THE LANGUAGE
----------------------------------------------------------------
More than 300 functions. Everything an analyst needs —
out of the box:
• Filtering, sorting, removing duplicates.
• Grouping, aggregation, pivot / unpivot tables.
• Conditional aggregates: sumif, countif, avgif, minif, maxif.
• Window functions: rownumber, rank, lag, lead, winsum.
• ABC analysis, Pareto analysis, anomaly detection
(iqr, zscore, percentile).
• Dates: year, month, day, adddays, datetrunc, calendar.
• Text: trim, clean, split, replacetext, deletetext.
• None handling: isnone, fillna, dropna, coalesce, noneif.
• SQL-like operations: join, groupby, having.
• Files: Excel, CSV, TXT, Parquet, SQLite.
• BigData mode on DuckDB: up to a billion rows, ~50 MB RAM.
• Charts: bar, line, pie, hist, scatter, box, heatmap, pair.
• HTML reports with interactive Plotly charts.
• Matrix ↔ DuckDB conversion in a single line.
----------------------------------------------------------------
THE MAIN IDEA — READABILITY
----------------------------------------------------------------
ArrayVator is built on a simple principle: code should be
understandable by a human, not only by a machine.
m = deleteif(m[:, "Department"] == "IT")
Reads in plain English: "delete rows where Department equals IT".
No braces, no indices, no commas — just a phrase.
Function names are short, meaningful, in English:
filterif, sort, groupby, sumif, vlookup, transpose.
You don't have to memorize them — the editor suggests them.
----------------------------------------------------------------
SMART AUTOCOMPLETE
----------------------------------------------------------------
The editor understands what you're typing and suggests.
Start typing "fil" — the editor suggests filterif.
Type "впр" (Russian alias for VLOOKUP) — the editor suggests vlookup.
Type "суммапо" — the editor suggests sumif.
Autocomplete works:
• by partial function name (fil → filterif);
• by Russian aliases (впр → vlookup, сводная → pivot);
• by the first letter;
• with arrow-key navigation ↑ ↓;
• with insertion via Tab or Enter.
The candidate list appears right under the cursor — just like
in modern IDEs. Nothing has to be memorized.
----------------------------------------------------------------
LIVE HELP WITH EXAMPLES
----------------------------------------------------------------
On the right side of the editor — a live help panel.
Click a function name in your code and you'll see:
• SYNTAX — the exact call format.
• DESCRIPTION — what the function does.
• EXAMPLE — how to call it.
• MATRIX EXAMPLE — concrete input, code and output.
Help updates instantly on click. No switching windows,
no Googling. Everything — right next to your code.
If a function doesn't exist — the editor suggests similar
ones and hints at what you might have meant.
----------------------------------------------------------------
POWERFUL ERROR HANDLING WITH HINTS
----------------------------------------------------------------
Errors in ArrayVator are not dry messages — they are full
explanations. Every error includes:
• What's wrong (in plain language).
• Where exactly (line and column, with a ^ pointer).
• How to fix it (a concrete example of correct code).
• Why it's this way (an explanation of the language's logic).
Example error message:
❌ Error (line 3):
if x = 5 then
In the condition '=' (assignment) is used,
but '==' (comparison) is required.
Incorrect: if x = 5 then
Correct: if x == 5 then
💡 '=' — assigns a value.
'==' — compares values.
Plus — automatic hints:
• "Did you mean filterif?"
• "Missing closing parenthesis ')' — add it at the end."
• "The keyword 'then' is required after the if condition."
Errors are available in two languages — Russian and English —
switchable with a single setting.
----------------------------------------------------------------
BUILD .EXE IN TWO CLICKS
----------------------------------------------------------------
The signature feature of ArrayVator: you can turn your script
into a standalone .exe program and hand it to a colleague —
no Python install, no library install, no configuration.
How it works:
1. Write code in the ArrayVator editor.
2. Click "Export to EXE".
3. Set the program name — for example, MyReport.exe.
4. Get a folder with the .exe and all libraries.
Your colleague double-clicks the .exe — and it just works.
No installs. No dependencies. Just a file.
The compiler picks the right runner automatically:
• If the code only has tables and math — a compact MINIMAL
runner is built.
• If Excel or DuckDB is used — a DATA runner is built.
• If charts or reports are used — a FULL runner is built.
You don't have to think about this — the compiler chooses.
----------------------------------------------------------------
WHAT THE EDITOR DOES
----------------------------------------------------------------
ArrayVator Editor is a full development environment:
• Syntax highlighting (keywords, functions, variables,
strings, numbers, comments — each in its own color).
• Line numbers.
• Find and replace (case-sensitive and case-insensitive).
• Built-in output console.
• Working folder — next to the editor.
• Auto-save of settings.
• Dark and light themes.
• Russian and English interface.
• Configurable fonts and highlight palette.
• Help panel that updates on click.
• Autocomplete with aliases.
• Error handling with human-readable hints.
All of this — in a single window. No external dependencies.
----------------------------------------------------------------
WHO THIS LANGUAGE IS FOR
----------------------------------------------------------------
• Analyst — quickly count, group, plot.
• Economist — build summaries by department and quarter.
• Marketer — run ABC analysis and find anomalies.
• Accountant — process exports from Excel or accounting systems.
• Researcher — clean data and compute statistics.
• Student — learn tabular work without Python.
• Manager — produce a report and pass it to colleagues.
ArrayVator is a language for people who work with data
but don't want to spend months learning Python and pandas.
----------------------------------------------------------------
WHAT THE LANGUAGE DOESN'T HAVE (AND NEVER WILL)
----------------------------------------------------------------
• Classes, inheritance, OOP.
• Lambdas and functional programming.
• Imports and package installs.
• Dependencies on external libraries (except BigData mode).
• Complex syntax for the sake of syntax.
The language is deliberately simple. Everything an analyst
doesn't need — has been removed.
----------------------------------------------------------------
SUMMARY
----------------------------------------------------------------
ArrayVator is:
✔ One readable language instead of ten libraries.
✔ 300+ built-in functions for data analysis.
✔ Smart autocomplete, including Russian aliases.
✔ Live help with examples right in the editor.
✔ Clear errors with hints and code examples.
✔ Build .exe in two clicks.
✔ Work with a billion rows via DuckDB.
✔ Charts and HTML reports out of the box.
✔ No dependencies when passing code to colleagues.
Simple. Readable. Fast. Yours.
================================================================
# ============================================================
# COMPLETE REFERENCE FOR THE ARRAYVATOR LANGUAGE
# ============================================================
# For beginners. Everything as detailed and clear as possible.
# Each function: purpose, syntax, example, output.
#
# IMPORTANT TERMS USED IN THIS REFERENCE:
#
# Scalar — a single value. One number, one text string,
# one true/false, one None.
# For example: 5, "Anna", true, None — all of these are scalars.
#
# Vector — one row of values or one column of values.
# Always one-dimensional (1D). Inside — only data,
# without a header.
# For example: [10, 20, 30] — a vector of 3 numbers.
#
# Matrix — a table with a header and data (2D).
# The first row — column headers.
# The rest of the rows — data.
# For example:
# ["Name", "Age";
# "Anna", 25;
# "Bob", 30]
#
# Slice — a part of a matrix (a column or a row).
# For example: m[:, "Salary"] — the entire "Salary" column.
# A vector is also a slice, but without a header.
#
# by — a parameter that tells the function "count by groups".
# Without by the function computes one number for the whole table.
# With by — computes separately for each group (for example,
# for each department or each class).
# ============================================================
# ============================================================
# 1. BASICS
# ============================================================
# ------------------------------------------------------------
# 1.1 What is None (empty value)
# ------------------------------------------------------------
# None is an empty value. Like an empty cell in Excel.
# It is always written the same way: None, none, NONE — these are the same.
# You cannot write: null, NULL, nan — those words do not exist in the language.
#
# Syntax: None
#
# Example:
x = None
print(x)
# Output: None
#
# Checking for emptiness:
r = isnone(None)
print(r)
# Output: True
# ------------------------------------------------------------
# 1.2 Boolean values (true / false)
# ------------------------------------------------------------
# true — true, false — false. Used in conditions.
#
# Syntax: true | false
#
# Example:
a = true
b = false
print(a, b)
# Output: True False
# ------------------------------------------------------------
# 1.3 Operators
# ------------------------------------------------------------
# Arithmetic:
# + addition
# - subtraction
# * multiplication
# / division (result is a floating-point number)
# % modulo (remainder)
# ^ power
# // integer division
#
# Comparison:
# == equal
# != not equal
# < less than
# > greater than
# <= less than or equal
# >= greater than or equal
#
# Logic (written as WORDS, not symbols):
# and — AND
# or — OR
# not — NOT
#
# You CANNOT write: && || ! — those symbols do not exist in the language.
#
# Example:
x = 5 + 3
y = 10 / 4
z = 2 ^ 10
ok = (x > 5) and (y < 3)
print(x, y, z, ok)
# Output: 8 2.5 1024 True
# ============================================================
# 2. CONTROL STRUCTURES
# ============================================================
# ------------------------------------------------------------
# 2.1 if-then-else
# ------------------------------------------------------------
# If the condition is true — the block after then is executed.
# If not — the block after else (if present).
#
# Syntax:
# if condition then { statements }
# if condition then { statements } else { statements }
#
# Example:
x = 10
if x > 5 then { print("greater") } else { print("less") }
# Output: greater
#
# Example without else:
x = 3
if x > 5 then { print("greater") }
# Outputs nothing.
# ------------------------------------------------------------
# 2.2 for loop (repeat N times)
# ------------------------------------------------------------
# Executes the block for each number in the range.
# Both ends are inclusive: 1 to 5 — this is 1, 2, 3, 4, 5.
#
# Syntax:
# for i = start to end do { statements }
# for i = start to end step S do { statements }
#
# Example:
for i = 1 to 5 do { print(i) }
# Output:
# 1
# 2
# 3
# 4
# 5
#
# Reverse order:
for i = 5 to 1 do { print(i) }
# Output: 5 4 3 2 1 (each on a new line)
#
# With step 2:
for i = 1 to 10 step 2 do { print(i) }
# Output: 1 3 5 7 9
#
# With step -2:
for i = 10 to 1 step -2 do { print(i) }
# Output: 10 8 6 4 2
#
# IMPORTANT: you cannot write "for i = 2 to end".
# Inside a loop you cannot use end — it is unclear what "end" refers to.
# You must use length functions:
# lenrow(m) — number of rows in matrix m
# lencol(m) — number of columns
# len(v) — number of elements in vector v
#
# Example — iterating over employees:
m = ["Name", "Salary";
"Anna", 50000;
"Bob", 60000;
"Eve", 55000]
print(m)
# Output:
# Name Salary
# Anna 50000
# Bob 60000
# Eve 55000
#
for i = 2 to lenrow(m) do { print(m[i, 1], m[i, 2]) }
# Output:
# Anna 50000
# Bob 60000
# Eve 55000
# ------------------------------------------------------------
# 2.3 while loop (while condition is true)
# ------------------------------------------------------------
# Repeats the block while the condition is true.
#
# Syntax: while condition { statements }
#
# Example:
i = 1
while i <= 3 { print(i); i = i + 1 }
# Output: 1 2 3
# ------------------------------------------------------------
# 2.4 break (exit loop)
# ------------------------------------------------------------
# Terminates the loop early.
#
# Syntax: break
#
# Example:
for i = 1 to 100 do { if i > 3 then { break }; print(i) }
# Output: 1 2 3
# ------------------------------------------------------------
# 2.5 try/catch (error handling)
# ------------------------------------------------------------
# If an error occurs in the try block, control passes
# to the catch block. There you can inspect the error text.
#
# Syntax:
# try { statements } catch { statements }
# try { statements } catch (e) { statements }
#
# Example:
try { m = OpenCSV("no_such.csv") } catch { print("Error:", error) }
# Output: Error: File not found: no_such.csv
#
# Example with a variable:
try { m = OpenCSV("no_such.csv") } catch (e) { print("Caught:", e) }
# Output: Caught: File not found: no_such.csv
# ============================================================
# 3. CREATING DATA
# ============================================================
# ------------------------------------------------------------
# 3.1 matrix(R, C) — create a matrix
# ------------------------------------------------------------
# Creates a matrix of R rows by C columns.
# All cells are filled with None.
#
# Syntax: matrix(R, C)
#
# Example:
m = matrix(2, 3)
print(m)
# Output:
# None None None
# None None None
# ------------------------------------------------------------
# 3.2 vector(N) — create a vector
# ------------------------------------------------------------
# A vector is a single row of values.
# Creates a vector of N None elements.
#
# Syntax: vector(N)
#
# Example:
v = vector(4)
print(v)
# Output: [None, None, None, None]
# ------------------------------------------------------------
# 3.3 zeros / ones — zeros or ones
# ------------------------------------------------------------
# Syntax:
# zeros(R, C) — R×C matrix of zeros
# zeros(N) — vector of N zeros
# ones(R, C) — R×C matrix of ones
# ones(N) — vector of N ones
#
# Example:
m = zeros(2, 3)
print(m)
# Output:
# 0 0 0
# 0 0 0
#
v = ones(4)
print(v)
# Output: [1, 1, 1, 1]
# ------------------------------------------------------------
# 3.4 fill — fill with a value
# ------------------------------------------------------------
# Fills ALL cells with the given value.
#
# Syntax: fill(matrix, value)
#
# Example:
m = matrix(2, 2)
print(m)
# Output:
# None None
# None None
#
m = fill(m, 7)
print(m)
# Output:
# 7 7
# 7 7
# ------------------------------------------------------------
# 3.5 range / Number — sequence of numbers
# ------------------------------------------------------------
# Creates a sequence of numbers.
#
# Syntax:
# range(N) — [1, 2, ..., N]
# range(a:b) — [a, a+1, ..., b]
# range(a:b, step S) — with step S
#
# IMPORTANT: range works only in an assignment.
#
# Example:
m = matrix(5, 1)
print(m)
# Output:
# None
# None
# None
# None
# None
#
m[:, 1] = range(5)
print(m)
# Output:
# 1
# 2
# 3
# 4
# 5
#
m = matrix(5, 1)
print(m)
# Output:
# None
# None
# None
# None
# None
#
m[:, 1] = range(1:10, step 2)
print(m)
# Output:
# 1
# 3
# 5
# 7
# 9
# ------------------------------------------------------------
# 3.6 random — random numbers
# ------------------------------------------------------------
# Generates random numbers.
# Works ONLY in an assignment (not in print!).
#
# Syntax: random(start:end, precision)
# start:end — range (both ends inclusive)
# precision — 0 for integers, N for float with N decimal places
#
# Example:
x = random(0:10, 0)
print(x)
# Output: for example 7 (different each time)
#
m = matrix(2, 2)
print(m)
# Output:
# None None
# None None
#
m[all, all] = random(0:10, 0)
print(m)
# Output: for example
# 3 8
# 1 9
# ============================================================
# 4. INDEXING AND ASSIGNMENT
# ============================================================
# ------------------------------------------------------------
# 4.1 Index forms
# ------------------------------------------------------------
# An index is a way to access a cell, a row, or a column.
#
# Forms:
# m[N, M] — cell (row N, column M)
# m[N, :] — the whole row N
# m[:, M] — the whole column M
# m[:, "Name"] — the whole column by name
# m[N:M, K:L] — range (rows N..M, columns K..L)
# m[last K, :] — last K rows
# m[:, last K] — last K columns
# m[end, :] — last row
# m[:, end] — last column
# m[:, end+1] — a new column to the RIGHT of the last one
#
# Example:
m = ["Name", "Age", "Department";
"Anna", 25, "IT";
"Bob", 30, "HR";
"Eve", 28, "IT"]
print(m)
# Output:
# Name Age Department
# Anna 25 IT
# Bob 30 HR
# Eve 28 IT
#
print(m[1, 1])
# Output: Anna
#
print(m[1, :])
# Output: ["Anna", 25, "IT"]
#
print(m[:, "Department"])
# Output: ["IT", "HR", "IT"]
#
print(m[1:2, 1:2])
# Output:
# Anna 25
# Bob 30
#
print(m[end, :])
# Output: ["Eve", 28, "IT"]
#
print(m[:, end])
# Output: ["IT", "HR", "IT"]
#
print(m[last 2, :])
# Output:
# Bob 30 HR
# Eve 28 IT
# ------------------------------------------------------------
# 4.2 Reading headers
# ------------------------------------------------------------
# m[0, :] — this is the vector of headers.
#
# Example:
m = ["Name", "Age"; "Anna", 25]
print(m)
# Output:
# Name Age
# Anna 25
#
h = m[0, :]
print(h)
# Output: ["Name", "Age"]
# ------------------------------------------------------------
# 4.3 Assigning a single cell
# ------------------------------------------------------------
# Syntax: m[row, column] = value
#
# Example:
m = ["Name", "Salary";
"Anna", 50000;
"Bob", 60000]
print(m)
# Output:
# Name Salary
# Anna 50000
# Bob 60000
#
m[1, 2] = 55000
print(m)
# Output:
# Name Salary
# Anna 55000
# Bob 60000
# ------------------------------------------------------------
# 4.4 Assigning a header
# ------------------------------------------------------------
# The header is the 0-th row.
# Syntax: m[0, :] = [...]
#
# Example:
m = matrix(3, 2)
print(m)
# Output:
# None None
# None None
# None None
#
m[0, :] = ["Name", "Salary"]
m[1, :] = ["Anna", 50000]
m[2, :] = ["Bob", 60000]
print(m)
# Output:
# Name Salary
# Anna 50000
# Bob 60000
# ------------------------------------------------------------
# 4.5 Assigning a whole column
# ------------------------------------------------------------
# Syntax: m[:, "Name"] = vector | scalar
#
# Example by name:
m = ["Name", "Salary";
"Anna", 50000;
"Bob", 60000]
print(m)
# Output:
# Name Salary
# Anna 50000
# Bob 60000
#
m[:, "Salary"] = [70000, 80000]
print(m)
# Output:
# Name Salary
# Anna 70000
# Bob 80000