From 71f4c886ece16c2f8f1c52b86298cd348db37b8f Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 27 Nov 2018 23:19:49 -0800 Subject: New range testing functions. * eval.c (eval_init): Register in-range and in-range* intrinsics. * lib.c (in_range, in_range_star): New functions. * lib.h (in_range, in_range_star): Declared. * txr.1: Documented. --- txr.1 | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index 76e4f629..c2636c81 100644 --- a/txr.1 +++ b/txr.1 @@ -21384,6 +21384,58 @@ of a range. Note that these functions are not accessors, which is because ranges are immutable. +.coNP Functions @ in-range and @ in-range* +.synb +.mets (in-range < range << value ) +.mets (in-range* < range << value ) +.syne +.desc +The +.code in-range +and +.code in-range* +functions test whether the +.meta value +argument lies in the range represented by the +.meta range +argument, indicating the Boolean result using one of the values +.code t +or +.codn nil . + +The +.meta range +argument must be a range object. + +It is expected that the range object's +.code from +value does not exceed the +.code to +value; a reversed range is considered empty. + +The +.code in-range* +function differs from +.code in-range +in that it excludes the +upper endpoint. + +The implicit comparison against the range endpoints is performed +using the +.code less +and +.code lequal +functions, as appropriate. + +The following equivalences hold: + +.cblk + (in-range r x) <--> (and (lequal (from r) x) + (lequal (to r) x)) + + (in-range* r x) <--> (and (lequal (from r) x) + (less (to r) x)) +.cble .SS* Characters and Strings .coNP Function @ mkstring .synb -- cgit v1.2.3