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

find_index: test support elem

This commit is contained in:
Justin Lin
2022-04-01 08:15:45 +08:00
parent f8f91df05a
commit fafd073840
2 changed files with 14 additions and 6 deletions

View File

@@ -19,5 +19,7 @@ new:
- lemniscate_curve? - lemniscate_curve?
- perlin_sphere? - perlin_sphere?
- find_index: test support elem
deprecated: deprecated:
rails2sections: use m_transpose rails2sections: use m_transpose

View File

@@ -9,9 +9,15 @@
**/ **/
function find_index(lt, test) = function find_index(lt, test) =
let( is_function(test) ? (
leng = len(lt), let(
indices = [for(i = 0; i < leng && !test(lt[i]); i = i + 1) undef], leng = len(lt),
leng_indices = len(indices) indices = [for(i = 0; i < leng && !test(lt[i]); i = i + 1) undef],
) leng_indices = len(indices)
leng_indices == leng ? -1 : leng_indices; )
leng_indices == leng ? -1 : leng_indices
) : (
let(found = search([key], bucket)[0])
found == [] ? - 1 : found
);