From f2e197dcd31d737bf23816107343f67e2bf6dd8e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku <kaz@kylheku.com> Date: Thu, 13 Aug 2015 21:47:02 -0700 Subject: New function, clamp. * eval.c (eval_init): Register clamp as intrinsic function. * lib.c (clamp): New function. * lib.h (clamp): Declared. * txr.1: Documented. --- txr.1 | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'txr.1') 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 ]) -- cgit v1.2.3