diff --git a/compiler/src/IR.hs b/compiler/src/IR.hs index 55228d1..0c12310 100644 --- a/compiler/src/IR.hs +++ b/compiler/src/IR.hs @@ -292,6 +292,7 @@ instance WellFormedIRCheck IRExpr where , "_setFailureRate" , "sleep" , "spawn" + , "sqrt" , "substring" , "stringToInt" , "restore" diff --git a/rt/src/builtins/math.mts b/rt/src/builtins/math.mts index 66b51f6..0c61535 100644 --- a/rt/src/builtins/math.mts +++ b/rt/src/builtins/math.mts @@ -26,5 +26,12 @@ export function BuiltinMath > (Base:T assertIsNumber(arg); return this.runtime.ret(new LVal(Math.floor(arg.val), arg.lev, arg.tlev)); }) + + sqrt = mkBase((arg) => { + assertIsNumber(arg); + return this.runtime.ret(new LVal(Math.sqrt(arg.val), arg.lev, arg.tlev)); + }) + + } } \ No newline at end of file