summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-07-18 06:25:31 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-07-18 06:25:31 -0700
commit0585569fd3754995ef1196959978911c3e4510b5 (patch)
treeb743d9ecee9c3d7c44e9bcdac3df44dd458657cd /lib.c
parentda270249da63b6a677a03ab50eed9fddb2ac8093 (diff)
downloadtxr-0585569fd3754995ef1196959978911c3e4510b5.tar.gz
txr-0585569fd3754995ef1196959978911c3e4510b5.tar.bz2
txr-0585569fd3754995ef1196959978911c3e4510b5.zip
new function: nth
Just the ANSI CL nth for lists. * eval.c (eval_init): Register nth intrinsic. * lib.c (nth): New function. * lib.h (nth): Declared. * share/txr/stdlib/place.tl (nth): New place macro, trivially takes care of making nth an accessor. Place macros are terrific! * txr.1: Documented.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 58737f69..66142ec1 100644
--- a/lib.c
+++ b/lib.c
@@ -674,6 +674,11 @@ val nthcdr(val pos, val list)
return list;
}
+val nth(val pos, val list)
+{
+ return car(nthcdr(pos, list));
+}
+
val nthlast(val pos, val list)
{
val iter = list;