mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-25 23:46:32 +02:00
refactor: extract a template
This commit is contained in:
11
src/util/_impl/_find_eq_search_some.scad
Normal file
11
src/util/_impl/_find_eq_search_some.scad
Normal file
@@ -0,0 +1,11 @@
|
||||
_find_eq_search = function(lt, target, eq)
|
||||
let(found = search([target], lt)[0])
|
||||
found == [] ? -1 : found;
|
||||
|
||||
_find_eq_some = function(lt, target, eq)
|
||||
let(
|
||||
leng = len(lt),
|
||||
indices = [for(i = 0; i < leng && !eq(lt[i], target); i = i + 1) undef],
|
||||
leng_indices = len(indices)
|
||||
)
|
||||
leng_indices == leng ? -1 : leng_indices;
|
@@ -1,16 +1,6 @@
|
||||
use <_hashmap_put_impl.scad>;
|
||||
|
||||
_find_eq_search = function(lt, target, eq)
|
||||
let(found = search([target], lt)[0])
|
||||
found == [] ? -1 : found;
|
||||
|
||||
_find_eq_some = function(lt, target, eq)
|
||||
let(
|
||||
leng = len(lt),
|
||||
indices = [for(i = 0; i < leng && !eq(lt[i], target); i = i + 1) undef],
|
||||
leng_indices = len(indices)
|
||||
)
|
||||
leng_indices == leng ? -1 : leng_indices;
|
||||
include <../../_impl/_find_eq_search_some.scad>;
|
||||
|
||||
function _hashmap(kv_lt, leng, buckets, b_numbers, eq, hash) =
|
||||
let(
|
||||
|
Reference in New Issue
Block a user