From cd36d92b2a64ba48421f97c1ca3ce478d0ecd8c2 Mon Sep 17 00:00:00 2001 From: mryouse Date: Wed, 15 Jun 2022 04:39:57 +0000 Subject: implement floor --- interpreter.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'interpreter.py') diff --git a/interpreter.py b/interpreter.py index 067681f..63b9187 100644 --- a/interpreter.py +++ b/interpreter.py @@ -10,6 +10,7 @@ import subprocess import shlex import random import sys +import math @dataclass @@ -849,3 +850,8 @@ def interpretUseAs(symbol, args, env, ns): # TODO takes a symbol as its second, that may be wrong GLOBALS.register("use-as", Builtin(interpretUseAs, [Arg("filename", TypeEnum.STRING, False, False), Arg("namespace", TypeEnum.ANY, False, True)])) + +def interpretFloor(symbol, args, env, ns): + return Int(math.floor(args[0].value)) + +GLOBALS.register("floor", Builtin(interpretFloor, [Arg("floor", TypeEnum.NUMBER, False, False)])) -- cgit v1.2.3