-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime.js
More file actions
105 lines (85 loc) · 1.9 KB
/
runtime.js
File metadata and controls
105 lines (85 loc) · 1.9 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
// These are functions that will be appended to the generated .js file
function አውጣ(...args) {
console.log(...args);
}
function ደምር(...args) {
if (args.length === 0) return NaN;
const init = 0;
const sum = args.reduce((prev, curr) => prev + curr, init);
return sum;
}
function ቀንስ(...args) {
if (args.length === 0) return NaN;
const init = args[0] * 2;
const diff = args.reduce((prev, curr) => prev - curr, init);
return diff;
}
function አብዛ(...args) {
if (args.length === 0) return NaN;
const init = 1;
const mult = args.reduce((prev, curr) => prev * curr, init);
return mult;
}
function ክፈል(...args) {
if (args.length === 0) return NaN;
const init = args[0] * args[0];
const div = args.reduce((prev, curr) => prev / curr, init);
return div;
}
function ሞጁሎ(x, y) {
return x % y;
}
function ካሬ_ሥር(x) {
return Math.sqrt(x);
}
function ከፍ_አድርግ(x, y) {
return Math.pow(x, y);
}
function ወደ_ታች(x) {
return Math.floor(x);
}
function ወደ_ላይ(x) {
return Math.ceil(x);
}
function አገናኝ(s1, s2) {
return s1 + s2;
}
function እኩል_ነው(x, y) {
return x === y;
}
function ያንሳል(x, y) {
return x < y;
}
function ይበልጣል(x, y) {
return x > y;
}
function ከሆነ(cond, consequent, alternate) {
if (cond) return consequent();
else return alternate();
}
function ወይም(cond1, cond2) {
return cond1 || cond2;
}
function እና(cond1, cond2) {
return cond1 && cond2;
}
function እዚህ(iterable, index) {
return iterable[index];
}
function ድገም(string, times) {
let result = '';
for (let i = 0; i < times; i++) {
result += string;
}
return result;
}
function ክልል(start, end) {
const result = [];
for (let i = start; i < end; i++) {
result.push(i);
}
return result;
}
function ለእያንዳንዱ(arr, fun) {
arr.forEach((e) => fun(e));
}