summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-08-13 21:47:02 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-08-13 21:47:02 -0700
commitf2e197dcd31d737bf23816107343f67e2bf6dd8e (patch)
treeecdefacfe4177012fae54ae74d8c309eab336767 /txr.1
parent4b308561021d4dedd7e83e5df30534d1fdde2216 (diff)
downloadtxr-f2e197dcd31d737bf23816107343f67e2bf6dd8e.tar.gz
txr-f2e197dcd31d737bf23816107343f67e2bf6dd8e.tar.bz2
txr-f2e197dcd31d737bf23816107343f67e2bf6dd8e.zip
New function, clamp.
* eval.c (eval_init): Register clamp as intrinsic function. * lib.c (clamp): New function. * lib.h (clamp): Declared. * txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.138
1 files changed, 38 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index fe7a8536..1e25f8e8 100644
--- a/txr.1
+++ b/txr.1
@@ -23686,6 +23686,44 @@ Thus
means
.codn (max (max a b) c) .
+.coNP Function @ clamp
+.synb
+.mets (clamp < low < high << val )
+.syne
+.desc
+The
+.code clamp
+function clamps value
+.meta val
+into the range
+.meta low
+to
+.metn high .
+
+The
+.code clamp
+function returns
+.meta low
+if
+.meta val
+is less than
+.metn low .
+If
+.meta val
+is greater than or equal to
+.metn low ,
+but less than
+.metn high ,
+then it returns
+.metn val .
+Otherwise it returns
+.meta high .
+
+More precisely,
+.code (clamp a b c)
+is equivalent to
+.codn (max a (min b c)) .
+
.coNP Functions @, int-str @ flo-str and @ num-str
.synb
.mets (int-str < string <> [ radix ])