-
Notifications
You must be signed in to change notification settings - Fork 2
/
types.ts
244 lines (162 loc) · 3.73 KB
/
types.ts
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
// Constants defining the reserved names and functions of Desmos.
export const SINGLE_CHARACTER_VARIABLES =
/^Pi|Xi|mp|mu|nu|pi|pm|xi|Phi|Psi|chi|div|eta|mid|phi|psi|rho|tau|beta|iota|perp|zeta|Delta|Gamma|Omega|Sigma|Theta|alpha|delta|gamma|infty|kappa|omega|sigma|theta|times|varpi|Lambda|lambda|varphi|varrho|Upsilon|digamma|epsilon|upsilon|varkappa|varsigma|vartheta|nparallel|varepsilon/
// Typings are in this format:
// fn_name arg1 arg2 -> return_type
//
// Types can be any of the following:
// R real number
// C complex number
// D distribution
// Q color
// P polygon
// LR list of real numbers
// LC list of complex numbers
// LD list of distributions
// LQ list of colors
// LP list of polygons
// X display only (cannot be used in other operations)
//
// Note that any function whose inputs are all
// real or complex numbers will automatically
// have an overload where each argument is a list.
//
// For example,
// arccos R -> R
// automatically has these overloads available:
// arccos LR -> LR
//
// To note the presence of a complex alternative,
// such as c_sin or c_cos, mark the alternative
// with a "+" sign at the beginning of its name.
// The alternative's name is assumed to be "c_...".
const TYPINGS_SOURCE = `
arccos R -> R
arccosh R -> R
arccot R -> R
arccoth R -> R
arccsc R -> R
arccsch R -> R
arcsec R -> R
arcsech R -> R
arcsin R -> R
arcsinh R -> R
arctan R -> R
arctan R R -> R
arctanh R -> R
binomialdist R -> D
binomialdist R R -> D
boxplot LR -> X
cdf D R -> R
ceil R -> R
corr LR LR -> R
cos R -> R
+cos C -> C
cosh R -> R
cot R -> R
coth R -> R
cov LR LR -> R
covp LR LR -> R
csc R -> R
+csc C -> C
csch R -> R
distance C C -> R
dotplot LR -> X
exp R -> R
+exp C -> C
floor R -> R
gcd R -> R
gcd R R -> R
histogram LR -> R
histogram LR R -> R
hsv R R R -> Q
inversecdf LR -> R
inversecdf LR R -> R
ittest LR LR -> X
join R R -> LR
join C C -> LC
join D D -> LD
join Q Q -> LQ
lcm R -> R
lcm R R -> R
length LR -> R
length LC -> R
length LD -> R
length LQ -> R
length LP -> R
ln R -> R
+ln C -> C
log R -> R
+log C -> C
mad LR -> R
max LR -> R
mean LR -> R
+mean LC -> C
median LR -> R
midpoint C C -> C
min LR -> R
mod R R -> R
normaldist -> D
normaldist R -> D
normaldist R R -> D
pdf D R -> R
poissondist R -> D
polygon C C -> P
polygon LC -> P
quantile LR R -> R
quartile LR R -> R
random -> R
random R -> LR
random R R -> LR
rgb R R R -> Q
round R -> R
sec R -> R
+sec C -> C
sech R -> R
shuffle LR -> LR
shuffle LC -> LC
shuffle LD -> LD
shuffle LQ -> LQ
shuffle LP -> LP
sign R -> R
+sign C -> C
sin R -> R
+sin C -> C
sinh R -> R
sort LR -> LR
spearman LR LR -> R
stats LR -> X
stddev LR -> R
stddevp LR -> R
stdev LR -> R
stdevp LR -> R
tan R -> R
+tan C -> C
tanh R -> R
tdist R -> D
total LR -> R
total LC -> C
tscore LR R -> R
ttest LR -> X
uniformdist -> D
uniformdist R -> D
uniformdist R R -> D
unique LR -> LR
unique LC -> LC
unique LD -> LD
unique LQ -> LQ
unique LP -> LP
var LR -> R
`.trim()
export const BUILT_INS_WITH_COMPLEX_ALTERNATIVES = TYPINGS_SOURCE.split("\n")
.filter((x): x is typeof x & `+${string}` => x.startsWith("+"))
.map((x) => x.split(" ", 1)[0]!.slice(1))
export const BUILT_INS = TYPINGS_SOURCE.split("\n")
.map((row) => row.split(" ")[0]!)
.filter((x): x is Exclude<typeof x, ""> => x != "")
.filter((x): x is Exclude<typeof x, `+${string}`> => !x.startsWith("+"))
.filter((item, index, array) => array.indexOf(item) == index)
export const IMPLICIT_FUNCTION_BUILT_INS =
"arccos arccosh arccot arccoth arccsc arccsch arcsec arcsech arcsin arcsinh arctan arctanh cos cosh cot coth csc csch distance dotplot ln log sec sech sin sinh tan tanh".split(
" ",
)