commit 0f61313c2da4475e6f114570e14f03f9add56b07
parent b58257e18417fa83974990f87692891aea156ed9
Author: Ed van Bruggen <edvb@uw.edu>
Date: Sun, 30 Dec 2018 21:19:12 -0800
Add mathematical constants
Diffstat:
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/tib/math.c b/tib/math.c
@@ -73,11 +73,15 @@ PRIM_COMPARE(gte, >=, ">=")
void
tib_env_math(Env env)
{
+ tisp_env_add(env, "pi", mk_dub(3.1415926535));
+ tisp_env_add(env, "e", mk_dub(2.7182818284));
+
tisp_env_add(env, "+", mk_prim(prim_add));
tisp_env_add(env, "-", mk_prim(prim_sub));
tisp_env_add(env, "*", mk_prim(prim_mul));
tisp_env_add(env, "/", mk_prim(prim_div));
tisp_env_add(env, "mod", mk_prim(prim_mod));
+
tisp_env_add(env, "<", mk_prim(prim_lt));
tisp_env_add(env, ">", mk_prim(prim_gt));
tisp_env_add(env, "<=", mk_prim(prim_lte));
diff --git a/tisp.h b/tisp.h
@@ -127,6 +127,7 @@ void skip_ws(Str str);
Val mk_int(int i);
Val mk_str(Env env, char *s);
Val mk_prim(Prim prim);
+Val mk_dub(double d);
Val mk_rat(int num, int den);
Val mk_sym(Env env, char *s);
Val mk_func(Val args, Val body, Env env);