summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 4d0c901b..6a662fbc 100644
--- a/lib.c
+++ b/lib.c
@@ -498,6 +498,19 @@ val last(val list)
return nullocp(p) ? list : deref(p);
}
+val nthcdr(val pos, val list)
+{
+ cnum n = c_num(pos);
+
+ if (n < 0)
+ uw_throwf(error_s, lit("nthcdr: negative index ~s given"), pos, nao);
+
+ while (n-- > 0)
+ list = cdr(list);
+
+ return list;
+}
+
loc ltail(loc cons)
{
while (cdr(deref(cons)))