diff options
author | Charlie Barto <bartoc@umich.edu> | 2014-03-27 00:21:19 -0400 |
---|---|---|
committer | Charlie Barto <bartoc@umich.edu> | 2014-03-27 00:21:19 -0400 |
commit | 491291ae24fe5901f4be918cbce2d6c21a0ae0e9 (patch) | |
tree | e8f4302c1187c5dc171d510c7177406a67b28c81 /lib | |
parent | 976fb18a8f99adb9ccec5a248fcf36be7d07388f (diff) | |
download | Nim-491291ae24fe5901f4be918cbce2d6c21a0ae0e9.tar.gz |
added usage example for lower bound
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/algorithm.nim | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/pure/algorithm.nim b/lib/pure/algorithm.nim index fb0ba5355..49d1ac972 100644 --- a/lib/pure/algorithm.nim +++ b/lib/pure/algorithm.nim @@ -63,6 +63,11 @@ proc lowerBound*[T](a: openarray[T], key: T, cmp: proc(x,y: T): int {.closure.}) ## ## `cmp` is the comparator function to use, the expected return values are the same as ## that of system.cmp + ## + ## example: + ## `var arr = @[1,2,3,5,6,7,8,9]` + ## `arr.insert(4, arr.lowerBound(4))` + ## after running the above arr is `[1,2,3,4,5,6,7,8,9]` result = a.low var pos = result var count, step: int |