From d226c45a9c066b569b4faded866062d83fc1cd8e Mon Sep 17 00:00:00 2001 From: Dustin Getz Date: Sat, 21 Dec 2024 11:51:52 -0500 Subject: [PATCH] clamp-left, clamp-right --- src/contrib/data.cljc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/contrib/data.cljc b/src/contrib/data.cljc index ec5a4fe0..9842d1d9 100644 --- a/src/contrib/data.cljc +++ b/src/contrib/data.cljc @@ -338,7 +338,9 @@ Qualify a keyword with a namespace. If already qualified, leave untouched. Nil-s ; org.apache.commons.lang3.StringUtils.containsIgnoreCase() ;(defn str-contains-ignore-case []) -(defn clamp [n left right] (min (max n left) right)) +(defn clamp-left [n left] (max n left)) ; when under limit, clamp up to larger +(defn clamp-right [n right] (min n right)) ; when exceeding limit, clamp down to smaller +(defn clamp [n left right] (clamp-right (clamp-left n left) right)) (tests (clamp 51 10 50) := 50