-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimplemented.oi
129 lines (109 loc) · 2.25 KB
/
implemented.oi
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
types:
number,
char,
bool,
string,
vector,
object,
function,
process,
string:
join(iterable) -> string
split(pattern) -> vector
index(substring) -> number
index(substring, from) -> number
range:
fit(x) -> number
unfit(x) -> number
collection:
add(...x) -> none
remove(...x) -> none
clear() -> none
stdlib:
functions:
int(x) -> number # convert value to integer or parse string
bool(x) -> bool
rand() -> number # Random.nextFloat()
len(x) -> number # alternative of .len attribute
vector(iterable) -> vector # create vector from iterable
chr(code) -> char # cast integer to char
keys(object) -> vector # vector of attribute names of OiObject
print(...) -> none
constants:
_version -> string
endl -> string
math:
functions:
sqrt(x) -> number
sin(x) -> number
cos(x) -> number
tan(x) -> number
atan(x) -> number
asin(x) -> number
acos(x) -> number
min(...numbers) -> number
max(...numbers) -> number
sum(vector) -> number
avg(vector) -> number
constants:
PI -> number
E -> number
Operators:
unary:
+, -, not, ! (same as not)
binary:
+, -, *, /, %, //, **
>, <, ==, !=, <=, >=,
ternary:
?:
Properties:
.len for strings and collections
# TODO:
- increment and decrement
- R-like ranges:
b = 1:10:2 # [1, 3, 5, 7, 9]
- Python-like try-except
Examples:
a = 1
b = 0
# functions
func f(c, d, e):
pass
# procedures
proc p(f, g, h):
pass
# if-elif-else operator
if a:
pass
elif b:
pass
else:
pass
# while loop
while a:
pass
# while with else
while a:
pass
else: # executed if loop wasn't broken by 'break'
pass
# one-word operators
break
continue
return
# foreach loop
for i : x:
pass
# for loop i from 0 to 99
for i : 100:
pass
# C-like for-loop
for i = 0; i < x; i+=1:
pass
# Extend script namespace with object members
include object
skip frames # <- interrupt and skip defined count of frames
# or
skip # <- just interrupt (same as skip 0)
wait milliseconds # <- wait defined count of milliseconds
wait 1000 # <- wait one second