diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-03-22 10:38:17 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-03-22 10:38:17 -0700 |
commit | 946c88ae095260a816aae8e1d5eacb32e4424718 (patch) | |
tree | 8fab69b645bd690e524ee4250f45bfa69737f3d5 | |
parent | 6254e4fa987437b1d785cae66122d707c886e144 (diff) | |
download | txr-946c88ae095260a816aae8e1d5eacb32e4424718.tar.gz txr-946c88ae095260a816aae8e1d5eacb32e4424718.tar.bz2 txr-946c88ae095260a816aae8e1d5eacb32e4424718.zip |
* arith.c (floorf, ceili, sine, cosi, atang, loga): New functions.
* eval.c (eval_init): New intrinsic functions registered:
floor, ceil, sin, cons, atan, log.
* lib.h (floorf, ceili, sine, cosi, atang, loga): Declared.
* txr.1: Doc stub section for new functions.
* txr.vim: Highighting added.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | arith.c | 30 | ||||
-rw-r--r-- | eval.c | 6 | ||||
-rw-r--r-- | lib.h | 6 | ||||
-rw-r--r-- | txr.1 | 2 | ||||
-rw-r--r-- | txr.vim | 5 |
6 files changed, 60 insertions, 2 deletions
@@ -1,5 +1,18 @@ 2012-03-22 Kaz Kylheku <kaz@kylheku.com> + * arith.c (floorf, ceili, sine, cosi, atang, loga): New functions. + + * eval.c (eval_init): New intrinsic functions registered: + floor, ceil, sin, cons, atan, log. + + * lib.h (floorf, ceili, sine, cosi, atang, loga): Declared. + + * txr.1: Doc stub section for new functions. + + * txr.vim: Highighting added. + +2012-03-22 Kaz Kylheku <kaz@kylheku.com> + * arith.c (int_flo): If sprintf produces something that doesn't begin with a digit, it's most likely NaN or Inf. We can turn that into an exception. @@ -1296,6 +1296,36 @@ inval: anum, bnum, nao); } +val floorf(val num) +{ + return flo(floor(c_flo(to_float(lit("floor"), num)))); +} + +val ceili(val num) +{ + return flo(ceil(c_flo(to_float(lit("ceil"), num)))); +} + +val sine(val num) +{ + return flo(sin(c_flo(to_float(lit("sin"), num)))); +} + +val cosi(val num) +{ + return flo(cos(c_flo(to_float(lit("cos"), num)))); +} + +val atang(val num) +{ + return flo(atan(c_flo(to_float(lit("atan"), num)))); +} + +val loga(val num) +{ + return flo(log(c_flo(to_float(lit("log"), num)))); +} + /* * TODO: replace this text-based hack! */ @@ -2187,6 +2187,12 @@ void eval_init(void) reg_fun(intern(lit("exptmod"), user_package), func_n3(exptmod)); reg_fun(intern(lit("sqrt"), user_package), func_n1(sqroot)); reg_fun(intern(lit("gcd"), user_package), func_n2(gcd)); + reg_fun(intern(lit("floor"), user_package), func_n1(floorf)); + reg_fun(intern(lit("ceil"), user_package), func_n1(ceili)); + reg_fun(intern(lit("sin"), user_package), func_n1(sine)); + reg_fun(intern(lit("cos"), user_package), func_n1(cosi)); + reg_fun(intern(lit("atan"), user_package), func_n1(atang)); + reg_fun(intern(lit("log"), user_package), func_n1(loga)); reg_fun(intern(lit("fixnump"), user_package), func_n1(fixnump)); reg_fun(intern(lit("bignump"), user_package), func_n1(bignump)); reg_fun(intern(lit("floatp"), user_package), func_n1(floatp)); @@ -426,6 +426,12 @@ val exptv(val nlist); val exptmod(val base, val exp, val mod); val sqroot(val anum); val gcd(val anum, val bnum); +val floorf(val); +val ceili(val); +val sine(val); +val cosi(val); +val atang(val); +val loga(val); val string_own(wchar_t *str); val string(const wchar_t *str); val string_utf8(const char *str); @@ -6649,6 +6649,8 @@ Certain object types have a custom equal function. .SS Arithmetic function abs +.SS Arithmetic functions floor, ceil, sin, cos, atan, log + .SS Functions fixnump, bignump, integerp, floatp, numberp .SS Functions zerop, evenp, oddp @@ -43,8 +43,9 @@ syn keyword txl_keyword contained reverse ldiff flatten lazy-flatten syn keyword txl_keyword contained memq memql memqual tree-find some syn keyword txl_keyword contained remq remql remqual syn keyword txl_keyword contained all none eq eql equal + - * / abs trunc mod -syn keyword txl_keyword contained expt exptmod sqrt gcd fixnump bignump -syn keyword txl_keyword contained integerp floatp +syn keyword txl_keyword contained expt exptmod sqrt gcd +syn keyword txl_keyword contained floor ceil sin cos atan log +syn keyword txl_keyword contained fixnump bignump integerp floatp syn keyword txl_keyword contained numberp zerop evenp oddp > syn keyword txl_keyword contained zerop evenp oddp > < >= <= max min syn keyword txl_keyword contained search-regex match-regex regsub |