summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-11-15 07:15:15 -0800
committerKaz Kylheku <kaz@kylheku.com>2023-11-15 07:15:15 -0800
commita8eba5d882105580383cf0da91d87c2477440f37 (patch)
tree15f74b84a2ab5485bc71aeef8bb6f288bde5a19d /lib.c
parent393ccf4a29c6b157f758fce6bcdcb9017ef74dc0 (diff)
downloadtxr-a8eba5d882105580383cf0da91d87c2477440f37.tar.gz
txr-a8eba5d882105580383cf0da91d87c2477440f37.tar.bz2
txr-a8eba5d882105580383cf0da91d87c2477440f37.zip
New accessor: mref.
* eval.c (eval_init): Register mref intrinsic. * lib.[ch] (mref): New function. * stdlib/place.tl (sys:mref1): New place. (mref): New place macro, defined in terms of sys:merf1, ref place and mref function. * tests/012/seq.tl: New tests. * txr.1: Documented.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 515d5439..4ce12556 100644
--- a/lib.c
+++ b/lib.c
@@ -13476,6 +13476,18 @@ val dwim_del(val place_p, val seq, val ind_range)
}
}
+val mref(val obj, varg args)
+{
+ cnum index = 0;
+
+ while (args_more(args, index)) {
+ val idx = args_get(args, &index);
+ obj = funcall1(obj, idx);
+ }
+
+ return obj;
+}
+
val butlast(val seq, val idx)
{
if (listp(seq)) {