diff --git a/src/experimental/note.md b/src/experimental/note.md index d4a79cf5..0da0f497 100644 --- a/src/experimental/note.md +++ b/src/experimental/note.md @@ -19,5 +19,7 @@ new: - lemniscate_curve? - perlin_sphere? +- find_index: test support elem + deprecated: rails2sections: use m_transpose \ No newline at end of file diff --git a/src/util/find_index.scad b/src/util/find_index.scad index 84efa26d..9739941d 100644 --- a/src/util/find_index.scad +++ b/src/util/find_index.scad @@ -9,9 +9,15 @@ **/ function find_index(lt, test) = - let( - leng = len(lt), - indices = [for(i = 0; i < leng && !test(lt[i]); i = i + 1) undef], - leng_indices = len(indices) - ) - leng_indices == leng ? -1 : leng_indices; \ No newline at end of file + is_function(test) ? ( + let( + leng = len(lt), + indices = [for(i = 0; i < leng && !test(lt[i]); i = i + 1) undef], + leng_indices = len(indices) + ) + leng_indices == leng ? -1 : leng_indices + ) : ( + let(found = search([key], bucket)[0]) + found == [] ? - 1 : found + ); + \ No newline at end of file