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 /share | |
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 'share')
-rw-r--r-- | share/txr/stdlib/place.tl | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/share/txr/stdlib/place.tl b/share/txr/stdlib/place.tl index 5b22e589..f8bbd580 100644 --- a/share/txr/stdlib/place.tl +++ b/share/txr/stdlib/place.tl @@ -972,3 +972,6 @@ (have-n ^(sub ,obj 0 (- (max ,n 0)))) (t ^(sub ,obj 0 -1)))) + +(define-place-macro nth (index obj) + ^(car (nthcdr ,index ,obj))) |