From fe1d0cb216b54a511ab9e3dc4f41b3ce09075997 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 7 Mar 2024 19:45:01 -0800 Subject: New function: rangeref. Because ranges can be iterated like sequences, and are identified as vector-like, they have to support indexing. However, ranges already have semantics as a function: with a sequence argument, they slice it. Let's put the semantics into a function called rangeref, so it can be coherently documented. * eval.c (eval_init): Register rangeref intrinsic. * lib.c (generic_funcall): Range as a function works in terms of rangeref. (ref): Handle RNG case via rangeref. (rangeref): New function. * lib.h (rangeref): Declared. * tests/012/seq.tl: New tests. --- lib.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib.h') diff --git a/lib.h b/lib.h index 2c1e307c..69b7ea97 100644 --- a/lib.h +++ b/lib.h @@ -1442,6 +1442,7 @@ val set_from(val range, val from); val set_to(val range, val to); val in_range(val range, val num); val in_range_star(val range, val num); +val rangeref(val range, val ind); void out_str_char(wchar_t ch, val out, int *semi_flag, int regex); val obj_print_impl(val obj, val out, val pretty, struct strm_ctx *); val obj_print(val obj, val stream, val pretty); -- cgit v1.2.3