summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-02-09 02:57:15 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-02-09 02:57:15 -0800
commit9791175d2bb5175aa54379000bf19caf9b34a188 (patch)
tree43dbebaf2c3129d89e3ef15ff84ed179f6f3a2c2 /lib.c
parent703f9f9696fa27959d6a7f75e72446ced13fbcb1 (diff)
downloadtxr-9791175d2bb5175aa54379000bf19caf9b34a188.tar.gz
txr-9791175d2bb5175aa54379000bf19caf9b34a188.tar.bz2
txr-9791175d2bb5175aa54379000bf19caf9b34a188.zip
* eval.c (rperm_list, rperm_vec, rperm_str): n variable renamed
to k, for consistency with rperm. (rperm): Likewise, and the behavior in the k == zero case is changed to return a single empty permutation. (perm_while_fun, perm_index, perm_gen_fun_common, perm_init_common, perm_vec_gen_fill, perm_vec_gen_fun, perm_vec, perm_list_gen_fill, perm_list_gen_fun, perm_list, perm_str_gen_fill, perm_str_gen_fun, perm_str, perm): New static functions. (eval_init): perm registered as intrinsic. * lib.c (vecref_l): Bugfix: allow negative indices, just like vecref. * lib.h (three, four): New macros. * txr.1: Updated documentation for rperm. Documented perm.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 39928568..67784f4d 100644
--- a/lib.c
+++ b/lib.c
@@ -3918,6 +3918,8 @@ val *vecref_l(val vec, val ind)
{
cnum index = c_num(ind);
cnum len = c_num(length_vec(vec));
+ if (index < 0)
+ index = len + index;
if (index < 0 || index >= len)
uw_throwf(error_s, lit("vecref: ~s is out of range for vector ~s"),
ind, vec, nao);