-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCore.stella
135 lines (111 loc) · 2.75 KB
/
Core.stella
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
130
131
132
133
134
135
import @java System java.lang.System
import @java String java.lang.String
import @java Integer java.lang.Integer
import @java Double java.lang.Double
import @java Float java.lang.Float
import @java Function java.util.function.Function
import @java Predicate java.util.function.Predicate
import @java List java.util.List
import @java Codex stella.Codex
import @java Objects java.util.Objects
import @java Object java.lang.Object
fn println(msg: java.lang.String) = {
System.out.println(msg)
}
fn println(msg: boolean) = {
System.out.println(msg)
}
fn println(msg: int) = {
System.out.println(msg)
}
fn println(msg: double) = {
System.out.println(msg)
}
fn println(msg: float) = {
System.out.println(msg)
}
fn print(msg: java.lang.String) = {
System.out.print(msg)
}
fn print(msg: java.lang.Object) = {
System.out.print(msg)
}
fn println() = {
System.out.println()
}
fn stdIn() -> String = {
var reader = new java.io.BufferedReader {
new java.io.InputStreamReader { System.in }
}
reader.readLine()
}
fn map(function: Function) -> List extends List = {
this.stream().map(function).toList()
}
fn filter(predicate: Predicate) -> List extends List = {
this.stream().filter(predicate).toList()
}
fn equals(rhs: java.lang.Object) -> boolean extends java.lang.Object = {
Objects.equals(this, rhs)
}
fn notEquals(rhs: java.lang.Object) -> boolean extends java.lang.Object = {
!Objects.equals(this, rhs)
}
fn null() -> java.lang.Object = {
Codex.getNull()
}
fn toInt() -> int extends String = {
Integer.parseInt(this.strip())
}
fn toDouble() -> double extends String = {
Double.parseDouble(this.strip())
}
fn toInt() -> int extends double = {
Codex.toInt(this)
}
fn toDouble() -> double extends int = {
Codex.toDouble(this)
}
fn box() -> Integer extends int = {
Integer.valueOf(this)
}
fn box() -> Double extends double = {
Double.valueOf(this)
}
fn box() -> Float extends float = {
Float.valueOf(this)
}
fn unbox() -> int extends Integer = {
this.intValue()
}
fn unbox() -> double extends Double = {
this.doubleValue()
}
fn unbox() -> float extends Float = {
this.floatValue()
}
fn isNull() -> boolean extends java.lang.Object = {
Objects.isNull(this)
}
fn assertValue(condition: boolean) = {
Codex.assertValue(condition)
}
fn get(index: int) -> Object extends [Object] = {
Codex.get(this, index)
}
fn bitAnd(rhs: String) -> String extends String = {
Codex.concat(this, rhs)
}
fn bitAnd(rhs: String) -> String extends Object = {
if (this.isNull()) {
"null" & rhs
} else {
Codex.concat(this.toString(), rhs)
}
}
fn bitComplement() -> void extends Object = {
println(this)
}
fn println() -> void extends Object = {
System.out.println(this)
}