forked from R3D9477/haxe-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hx
68 lines (51 loc) · 2.32 KB
/
Main.hx
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
package;
class Main {
public static function main () {
//----------------------------------------------------------------------
trace('--- MAKE A NEW LIST OF INTEGERS ---');
var a = new List<Int>();
//----------------------------------------------------------------------
trace('--- List empty is empty: ' + a.isEmpty() + ' ---');
//----------------------------------------------------------------------
trace('--- ADD ELEMENTS TO END OF THE LIST ---');
a.add(3);
a.add(2);
a.add(1);
a.add(5);
a.add(6);
trace(a);
//----------------------------------------------------------------------
trace('--- List empty is empty: ' + a.isEmpty() + ' ---');
//----------------------------------------------------------------------
trace('--- Length of list: ' + a.length + ' ---');
//----------------------------------------------------------------------
trace('--- ADD ELEMENTS TO BEGIN OF THE LIST ---');
a.push(0);
a.push(20);
a.push(10);
a.push(50);
a.push(60);
trace(a);
//----------------------------------------------------------------------
trace('--- Get first element: ' + a.first() + ' ---');
//----------------------------------------------------------------------
trace('--- Get last element: ' + a.last() + ' ---');
//----------------------------------------------------------------------
trace('--- REMOVE ELEMENTS 3, 100, 50 AND 20 FROM LIST ---');
trace("Was removed element with index: " + a.remove(3));
trace("Was removed element with index: " + a.remove(100));
trace("Was removed element with index: " + a.remove(50));
trace("Was removed element with index: " + a.remove(20));
trace(a);
//----------------------------------------------------------------------
trace('--- LIST TO STRING ' + a.toString() + ' ---');
//----------------------------------------------------------------------
trace('--- LIST TO STRING WITH CUSTOM DELIMITERS: ' + a.join('-->') + ' ---');
//----------------------------------------------------------------------
trace('--- FILTRATION OF THE LIST ---');
trace(a.filter(function (i) { return i > 5 && i < 40; }));
//----------------------------------------------------------------------
trace('--- CHANGE THE REPRESENTATION OF THE ELEMENTS ---');
trace(a.map(function (i) { return i * 100; }));
}
}