1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-03-14 19:19:47 +01: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>;
function binary_search(sorted, target) =
function binary_search(sorted, target, lo = 0, hi = undef) =
_binary_search_impl(
sorted,
is_function(target) ? target : function(elem) elem == target ? 0 : elem > target ? 1 : -1,
0,
len(sorted) - 1
lo,
is_undef(hi) ? len(sorted) - 1 : hi
);