-
Notifications
You must be signed in to change notification settings - Fork 0
/
.stdlib.epc
111 lines (81 loc) · 1.56 KB
/
.stdlib.epc
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
func car(l)
daca lung(l) >= 1 atunci
ret l[0]
sfdaca
ret l
sffunc
func concat(l1, l2)
pt i=0; i<lung(l2); i=i+1 executa
l1 = l1 + l2[i]
sfpt
ret l1
sffunc
struct point
x = 0
y = 0
func translate(dx, dy)
x = x+dx
y = y+dy
scrie("translate was called\n")
sffunc
move = func(new_x, new_y)
x = new_x
y = new_y
sffunc
sfstruct
struct KeyVal
key = ""
val = ""
sfstruct
struct Dict
_d = {}
func insert(k, v)
kv = KeyVal()
kv.key = k
kv.val = v
_d = _d + kv
sffunc
func get(k, default)
daca lung(_d) == 0 atunci
ret default
sfdaca
pt i=lung(_d)-1; i>=0; i=i-1 executa
daca _d[i].key == k atunci
ret _d[i].val
sfdaca
sfpt
ret default
sffunc
func min()
m = _d[lung(_d)-1]
pt i=lung(_d)-1; i>=0; i=i-1 executa
daca get(_d[i].key, m.val) < m.val atunci
m = _d[i]
sfdaca
sfpt
ret m
sffunc
sfstruct
struct Node
left = 0
right = 0
key = 0
data = 0
sfstruct
func indexOf(needle, haystack)
pt i=0; i<lung(haystack); i=i+1 executa
daca needle == haystack[i] atunci
ret i
sfdaca
sfpt
ret -1
sffunc
func unique(list)
u = {list[0]}
pt i=1; i<lung(list); i=i+1 executa
daca -1 == indexOf(list[i], u) atunci
u = u + list[i]
sfdaca
sfpt
ret u
sffunc