aboutsummaryrefslogtreecommitdiff
path: root/test/arrays.tm
blob: 376dd6a527dd289f4040963220a2a163f8ee1fd1 (plain)
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
if yes
	>> [:Num32]
	= [] : [Num32]

if yes
	>> arr := [10, 20, 30]
	= [10, 20, 30]

	>> arr[1]
	= 10
	>> arr[-1]
	= 30

	>> #arr
	= 3

	sum := 0
	for x in arr
		sum += x
	>> sum
	= 60

	str := ""
	for i,x in arr
		str ++= "({i},{x})"
	>> str
	= "(1,10)(2,20)(3,30)"

if yes
	>> arr := [10, 20] ++ [30, 40]
	= [10, 20, 30, 40]

	>> arr ++= [50, 60]
	>> arr
	= [10, 20, 30, 40, 50, 60]

	>> arr ++= 70
	>> arr
	= [10, 20, 30, 40, 50, 60, 70]

if yes
	>> arr := [10, 20]
	>> copy := arr
	>> arr ++= 30
	>> arr
	= [10, 20, 30]
	>> copy
	= [10, 20]

// if yes
// 	>> arr := @[10, 20]
// 	>> copy := arr[]
// 	>> arr:insert(30)
// 	>> arr
// 	= @[10, 20, 30]
// 	>> copy
// 	= [10, 20]