mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-06 06:47:46 +02:00
refactor
This commit is contained in:
@@ -1,8 +1,20 @@
|
|||||||
use <../util/sum.scad>;
|
use <../util/sum.scad>;
|
||||||
|
|
||||||
function _str_hash(value) =
|
function _str_hash(value) =
|
||||||
let(s = str(value))
|
let(
|
||||||
sum([
|
chars = str(value),
|
||||||
for(i = len(s) - 1; i > -1; i = i - 1)
|
end = len(chars) - 1
|
||||||
ord(s[i]) * 31 ^ i
|
)
|
||||||
]);
|
end == 0 ? ord(chars[0]) :
|
||||||
|
let(cum_total = [for(i = 0, s = ord(chars[i]); i < end; i = i + 1, s = s + (ord(chars[i]) * 31 ^ i)) s])
|
||||||
|
cum_total[len(cum_total) - 1] + (ord(chars[end]) * 31 ^ i);
|
||||||
|
|
||||||
|
// sum([
|
||||||
|
// for(i = len(s) - 1; i > -1; i = i - 1)
|
||||||
|
// ord(s[i]) * 31 ^ i
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
let(end = len(lt) - 1)
|
||||||
|
end == 0 ? lt[0] :
|
||||||
|
let(cum_total = [for(i = 0, s = lt[0]; i < end; i = i + 1, s = s + lt[i]) s])
|
||||||
|
cum_total[len(cum_total) - 1] + lt[end];
|
Reference in New Issue
Block a user