From 414cc826c0a821c8aa30cc5e9fa62f48892c6c36 Mon Sep 17 00:00:00 2001 From: Aslan Askarov Date: Mon, 19 Feb 2024 10:58:00 +0100 Subject: [PATCH] sqrt --- compiler/src/IR.hs | 1 + rt/src/builtins/math.mts | 7 +++++++ 2 files changed, 8 insertions(+) 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