From 0585569fd3754995ef1196959978911c3e4510b5 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 18 Jul 2017 06:25:31 -0700 Subject: 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. --- share/txr/stdlib/place.tl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'share') 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))) -- cgit v1.2.3