diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-03-07 19:45:01 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-03-07 19:45:01 -0800 |
commit | fe1d0cb216b54a511ab9e3dc4f41b3ce09075997 (patch) | |
tree | 88c81759b5ba2efee3307509d4750523a5769283 /lib.h | |
parent | b5d92c7b65b7c8efd3c62da070b52326989dfe0b (diff) | |
download | txr-fe1d0cb216b54a511ab9e3dc4f41b3ce09075997.tar.gz txr-fe1d0cb216b54a511ab9e3dc4f41b3ce09075997.tar.bz2 txr-fe1d0cb216b54a511ab9e3dc4f41b3ce09075997.zip |
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.
Diffstat (limited to 'lib.h')
-rw-r--r-- | lib.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -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); |