1
0
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:
Justin Lin
2022-04-11 11:08:12 +08:00
parent a63bbb47fd
commit 233ae4b50a
2 changed files with 12 additions and 11 deletions

View 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;

View File

@@ -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(