1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-20 05:21:38 +02:00

add lo, hi params

This commit is contained in:
Justin Lin
2022-05-11 09:25:40 +08:00
parent de97253d92
commit dce855611c

View File

@@ -10,10 +10,10 @@
use <_impl/_binary_search_impl.scad>; use <_impl/_binary_search_impl.scad>;
function binary_search(sorted, target) = function binary_search(sorted, target, lo = 0, hi = undef) =
_binary_search_impl( _binary_search_impl(
sorted, sorted,
is_function(target) ? target : function(elem) elem == target ? 0 : elem > target ? 1 : -1, is_function(target) ? target : function(elem) elem == target ? 0 : elem > target ? 1 : -1,
0, lo,
len(sorted) - 1 is_undef(hi) ? len(sorted) - 1 : hi
); );