commit 5e36e1bf92f661ed6112fa06752d884d626ee813
parent cb66d5900f5ad9b1e611946ab75a39cbb01892f9
Author: Ed van Bruggen <edvb@uw.edu>
Date: Fri, 11 Oct 2019 23:45:55 -0700
Rename int and dec to integer and decimal
Diffstat:
2 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/test.c b/test.c
@@ -298,26 +298,26 @@ char *tests[][2] = {
{ "(member? \"quux\" (list 4.2 3 'quux))", "()" },
{ "(member? 'qux '(foo bar baz))", "()" },
- { "num/den", NULL },
- { "(numerator 3/2)", "3" },
- { "(numerator 1/2)", "1" },
- { "(numerator -4/2)", "-2" },
- { "(numerator 24)", "24" },
- { "(denominator 1/4)", "4" },
- { "(denominator 4/3)", "3" },
- { "(denominator 4/2)", "1" },
- { "(denominator 14/8)", "4" },
- { "(denominator -4)", "1" },
-
- { "dec/int", NULL },
- { "(dec 1/2)", "0.5" },
- { "(dec 3/-2)", "-1.5" },
- { "(dec 1)", "1.0" },
- { "(dec 3.14)", "3.14" },
- { "(int 1/2)", "0" },
- { "(int 3/-2)", "-1" },
- { "(int 1)", "1" },
- { "(int 3.14)", "3" },
+
+ { "numbers", NULL },
+ { "(decimal 1/2)", "0.5" },
+ { "(decimal 3/-2)", "-1.5" },
+ { "(decimal 1)", "1.0" },
+ { "(decimal 3.14)", "3.14" },
+ { "(integer 1/2)", "0" },
+ { "(integer 3/-2)", "-1" },
+ { "(integer 1)", "1" },
+ { "(integer 3.14)", "3" },
+ { "(numerator 3/2)", "3" },
+ { "(numerator 1/2)", "1" },
+ { "(numerator -4/2)", "-2" },
+ { "(numerator 24)", "24" },
+ { "(denominator 1/4)", "4" },
+ { "(denominator 4/3)", "3" },
+ { "(denominator 4/2)", "1" },
+ { "(denominator 14/8)", "4" },
+ { "(denominator -4)", "1" },
+
{ "round", NULL },
{ "(round 7/3)", "2" },
diff --git a/tibs/math.c b/tibs/math.c
@@ -99,15 +99,15 @@ prim_##NAME(Env env, Val args) \
}
/* define int and dec as identity functions to use them in the same macro */
-#define int(X) (X)
-#define dec(X) (X)
-PRIM_ROUND(int, 1)
-PRIM_ROUND(dec, 2)
+#define integer(X) (X)
+PRIM_ROUND(integer, 1)
+#undef integer
+#define decimal(X) (X)
+PRIM_ROUND(decimal, 2)
+#undef decimal
PRIM_ROUND(round, 0)
PRIM_ROUND(floor, 0)
PRIM_ROUND(ceil, 0)
-#undef int
-#undef dec
static Val
prim_add(Env env, Val args)
@@ -258,8 +258,8 @@ tib_env_math(Env env)
tsp_env_fn(numerator);
tsp_env_fn(denominator);
- tsp_env_fn(int);
- tsp_env_fn(dec);
+ tsp_env_fn(integer);
+ tsp_env_fn(decimal);
tsp_env_fn(floor);
tsp_env_fn(ceil);
tsp_env_fn(round);