@@ -57,7 +57,7 @@ export type UserVariable = {
5757
5858export type UserObject = UserVariable | UserFunction ;
5959
60- const RESERVED_VARIABLES = [
60+ export const RESERVED_VARIABLES = [
6161 "pi" ,
6262 "e" ,
6363 "ans" ,
@@ -89,7 +89,7 @@ const RESERVED_VARIABLES = [
8989 "nthroot" ,
9090 "arccos" ,
9191 "arctan" ,
92- "arcos " ,
92+ "arcsin " ,
9393 "lg" ,
9494 "degrees" ,
9595 "radians" ,
@@ -102,6 +102,20 @@ const RESERVED_VARIABLES = [
102102 "ℇ" ,
103103 "𝑒" ,
104104 "ℯ" ,
105+ "abs" ,
106+ "cosh" ,
107+ "sinh" ,
108+ "tanh" ,
109+ "sum" ,
110+ "variance" ,
111+ "min" ,
112+ "max" ,
113+ "round" ,
114+ "int" ,
115+ "lngamma" ,
116+ "frac" ,
117+ "sgn" ,
118+ "median" ,
105119] ;
106120const SYNTAX_ERRORS = [
107121 "UNEXPECTED_EOF" ,
@@ -254,7 +268,10 @@ export default function evaluate(
254268 ) ,
255269 )
256270 . with (
257- { type : "func" , name : P . union ( "lg" , "degrees" , "radians" ) } ,
271+ {
272+ type : "func" ,
273+ name : P . union ( "lg" , "degrees" , "radians" , "frac" , "sgn" ) ,
274+ } ,
258275 ( token ) => {
259276 // Custom methods with one argument
260277 const funcName = token . name ;
@@ -285,17 +302,23 @@ export default function evaluate(
285302 . otherwise ( ( ) => err ( { type : "INVALID_ARG_COUNT" } as const ) ) ;
286303 } ,
287304 )
288- . with ( { type : "func" , name : P . union ( "average" ) } , ( token ) => {
289- // Custom methods with unlimited params
290- const funcName = token . name ;
291- const func = functions [ funcName ] ;
305+ . with (
306+ {
307+ type : "func" ,
308+ name : P . union ( "average" , "sum" , "variance" , "min" , "max" , "median" ) ,
309+ } ,
310+ ( token ) => {
311+ // Custom methods with unlimited params
312+ const funcName = token . name ;
313+ const func = functions [ funcName ] ;
292314
293- const res = parseFunction ( ) ;
294- if ( res . isErr ( ) ) return err ( res . error ) ;
295- const args = res . value ;
315+ const res = parseFunction ( ) ;
316+ if ( res . isErr ( ) ) return err ( res . error ) ;
317+ const args = res . value ;
296318
297- return ok ( func ( ...args ) ) ;
298- } )
319+ return ok ( func ( ...args ) ) ;
320+ } ,
321+ )
299322 . with (
300323 {
301324 type : "func" ,
@@ -321,6 +344,12 @@ export default function evaluate(
321344 "csc" ,
322345 "cot" ,
323346 "cbrt" ,
347+ "abs" ,
348+ "sinh" ,
349+ "tanh" ,
350+ "cosh" ,
351+ "round" ,
352+ "lngamma" ,
324353 ) ,
325354 } ,
326355 ( token ) => {
0 commit comments