Published
Edited
Jun 26, 2019
Insert cell
md`# Dolos hash proof of concept`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function hash(str) {
let h = null;
for (const c of str) {
if (h === null) {
h = charValue(c);
} else {
h = ((h * base) % mod + charValue(c)) % mod
}
}
return h;
}
Insert cell
Insert cell
function rollingHash(oh, oc, nc, length) {
return (((oh + mod - (charValue(oc) * Math.pow(base, length - 1)) % mod ) * base) % mod + charValue(nc)) % mod
}
Insert cell
hash("abbr");
Insert cell
Insert cell
hash("bbra");
Insert cell
rollingHash(hash("abbr"), "a", "a", 4)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more