diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-11-20 20:23:17 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-11-20 20:23:17 -0800 |
commit | 7320959c0a70a679011d0a0e0d2e43c586f631ab (patch) | |
tree | 86b5c0d459d96f055839e8feafee95ef053f047a /arith.c | |
parent | d4b9a1e45899f86dbb9d5bef1f53fffa9dc05d44 (diff) | |
download | txr-7320959c0a70a679011d0a0e0d2e43c586f631ab.tar.gz txr-7320959c0a70a679011d0a0e0d2e43c586f631ab.tar.bz2 txr-7320959c0a70a679011d0a0e0d2e43c586f631ab.zip |
* arith.c (wrap_star, wrap): New functions.
* eval.c (eval_init): Registered wrap and wrap* intrinsics.
* lib.h (wrap_star, wrap): Declared.
* txr.1: wrap and wrap* documented.
Diffstat (limited to 'arith.c')
-rw-r--r-- | arith.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -938,6 +938,19 @@ divzero: uw_throw(numeric_error_s, lit("mod: division by zero")); } +val wrap_star(val start, val end, val num) +{ + val modulus = minus(end, start); + val num_off = minus(num, start); + val num_mod = mod(num_off, modulus); + return plus(start, num_mod); +} + +val wrap(val start, val end, val num) +{ + return wrap_star(start, succ(end), num); +} + static val to_float(val func, val num) { switch (type(num)) { |