summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-12-03 00:06:23 +0800
committerGitHub <noreply@github.com>2020-12-02 17:06:23 +0100
commitd2bf0fb43c40253e3959715fb1fdf866c04559c2 (patch)
tree031c580ee5c9eda344076c487e159accceedec5e /lib/system
parent148d614dffbc93f1d8e6e6de3e8e64f64115ccdd (diff)
downloadNim-d2bf0fb43c40253e3959715fb1fdf866c04559c2.tar.gz
small style changes and clarify clamp (#16228)
* [docs minor]better comparisons docs

* switch from PRNG to random module

* apply suggestions

* not compile

* Revert "switch from PRNG to random module"

This reverts commit 83b4d8946d7d677edac43b7675c41e230ba4e382.

* small style changes and clarify clamp
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/comparisons.nim14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/system/comparisons.nim b/lib/system/comparisons.nim
index 71096addd..d9c7f6782 100644
--- a/lib/system/comparisons.nim
+++ b/lib/system/comparisons.nim
@@ -4,14 +4,14 @@ proc `==`*[Enum: enum](x, y: Enum): bool {.magic: "EqEnum", noSideEffect.} =
   runnableExamples:
     type
       Enum1 = enum
-        Field1 = 3, Field2
+        field1 = 3, field2
       Enum2 = enum
-        Place1, Place2 = 3
+        place1, place2 = 3
     var
-      e1 = Field1
-      e2 = Enum1(Place2)
+      e1 = field1
+      e2 = Enum1(place2)
     assert e1 == e2
-    assert not compiles(e1 == Place2) # raises error
+    assert not compiles(e1 == place2) # raises error
 proc `==`*(x, y: pointer): bool {.magic: "EqRef", noSideEffect.} =
   ## Checks for equality between two `pointer` variables.
   runnableExamples:
@@ -251,7 +251,9 @@ proc max*[T](x: openArray[T]): T =
 
 proc clamp*[T](x, a, b: T): T =
   ## Limits the value `x` within the interval [a, b].
-  ## This proc is equivalent to `max(a, min(b, x))`.
+  ## This proc is equivalent to but fatser than `max(a, min(b, x))`.
+  ## 
+  ## **Note that** `a < b` is assuemed and no check for it.
   runnableExamples:
     assert (1.4).clamp(0.0, 1.0) == 1.0
     assert (0.5).clamp(0.0, 1.0) == 0.5