summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 29049969..3dd57738 100644
--- a/lib.c
+++ b/lib.c
@@ -310,7 +310,7 @@ val sixth(val cons)
val listref(val list, val ind)
{
if (lt(ind, zero))
- return nil;
+ ind = plus(ind, length_list(list));
for (; gt(ind, zero); ind = minus(ind, one))
list = cdr(list);
return car(list);
@@ -321,6 +321,9 @@ val *listref_l(val list, val ind)
val olist = list;
val oind = ind;
+ if (lt(ind, zero))
+ ind = plus(ind, length_list(list));
+
for (; gt(ind, zero) && list; ind = minus(ind, one))
list = cdr(list);
if (consp(list))