diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-07-18 06:25:31 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-07-18 06:25:31 -0700 |
commit | 0585569fd3754995ef1196959978911c3e4510b5 (patch) | |
tree | b743d9ecee9c3d7c44e9bcdac3df44dd458657cd /lib.c | |
parent | da270249da63b6a677a03ab50eed9fddb2ac8093 (diff) | |
download | txr-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.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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; |