summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-12-13 17:36:08 -0800
committerKaz Kylheku <kaz@kylheku.com>2011-12-13 17:36:08 -0800
commitef47dfe4fcb7c1be369ae83221386b9da6474a1e (patch)
treea2ac264811c80ad085eea5ea725b3bb6be8ba751 /lib.c
parent5d0f219ab35f9e214a063e968286ba01f4b54dbf (diff)
downloadtxr-ef47dfe4fcb7c1be369ae83221386b9da6474a1e.tar.gz
txr-ef47dfe4fcb7c1be369ae83221386b9da6474a1e.tar.bz2
txr-ef47dfe4fcb7c1be369ae83221386b9da6474a1e.zip
* arith.c (highest_bit): Linkage changed to static.
(abso, isqrt): New functions. (isqrt_fixnum): New static function. * eval.c (eval_init): Registered abs, sqrt and numberp instrinsics. * lib.c (numberp): New function. * lib.h (numberp, abso, isqrt): Declared. * mpi-patches/series: New patch added. * mpi-patches/faster-square-root: New patch added. * txr.1: Documentation stubs for new functions.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 21cfb68c..0062ac94 100644
--- a/lib.c
+++ b/lib.c
@@ -832,6 +832,20 @@ val bignump(val num)
return (is_ptr(num) && type(num) == BGNUM) ? t : nil;
}
+val numberp(val num)
+{
+ switch (tag(num)) {
+ case TAG_NUM:
+ return t;
+ case TAG_PTR:
+ if (num->t.type == BGNUM)
+ return t;
+ /* fallthrough */
+ default:
+ return nil;
+ }
+}
+
val plusv(val nlist)
{
if (!nlist)