From fde53bffd7ea707f70028ec42aa2d7cd225d4293 Mon Sep 17 00:00:00 2001 From: flaviut Date: Tue, 8 Apr 2014 18:00:44 -0400 Subject: Code example for `clamp` --- lib/system.nim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/system.nim b/lib/system.nim index 6de9f3a8a..f5b1c3fe5 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1507,7 +1507,11 @@ proc max*(x, y: float): float {.magic: "MaxF64", noSideEffect.} = {.pop.} proc clamp*[T](x, a, b: T): T = - ## limits the value ``x`` within the interval [a, b] + ## limits the value ``x`` within the interval [a, b] + ## + ## .. code-block:: Nimrod + ## assert((1.4).clamp(0.0, 1.0) == 1.0) + ## assert((0.5).clamp(0.0, 1.0) == 0.5) if x < a: return a if x > b: return b return x -- cgit 1.4.1-2-gfad0