aboutsummaryrefslogtreecommitdiff
path: root/neb/std/functools.py
diff options
context:
space:
mode:
authormryouse2022-07-07 03:47:22 +0000
committermryouse2022-07-07 03:47:22 +0000
commit46cefa721d145af17bee3696ef533d752989458c (patch)
treeccc9612b3103c1840f4d92636111171be11fb30b /neb/std/functools.py
parent9e07b83ff396a8986d86e3968c4df77ee302a6a0 (diff)
refactor: 'apply' to functools
Diffstat (limited to 'neb/std/functools.py')
-rw-r--r--neb/std/functools.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/neb/std/functools.py b/neb/std/functools.py
index 8a76e98..f83c49d 100644
--- a/neb/std/functools.py
+++ b/neb/std/functools.py
@@ -34,3 +34,11 @@ def interpretMap(symbol, args, env, ns):
FUNCTOOLS.register("map", Builtin("map", interpretMap, [Arg("func", TypeEnum.ANY), Arg("list", TypeEnum.LIST)], return_type=Type(":list")))
+# TODO I think this is wrong
+def interpretApply(symbol, args, env, ns):
+ func = args[0]
+ if not isinstance(func, Function):
+ raise InterpretPanic(symbol, "requires a symbol as its first argument", func)
+ return func.call(Expr([func] + args[1].args), env, ns)
+
+FUNCTOOLS.register("apply", Builtin("apply", interpretApply, [Arg("func", TypeEnum.ANY), Arg("list", TypeEnum.LIST)]))