rename function

This commit is contained in:
Joeri Exelmans 2025-05-10 14:45:50 +02:00
parent d363d73dbd
commit 1fa47d4abd
2 changed files with 8 additions and 8 deletions

View file

@ -1,5 +1,5 @@
import { pretty } from "../lib/util/pretty.js";
import { insert, emptyTrie, growKey, suggest } from "../lib/util/trie.js";
import { insert, emptyTrie, growPrefix, suggest } from "../lib/util/trie.js";
// insertion
const with1Item = insert(emptyTrie)('abba')('dancing queen');
@ -20,11 +20,11 @@ const with8Items = insert(with7Items)('')('hi!');
console.log(pretty(with8Items));
// grow key (for auto-complete)
console.log(growKey(with6Items)("a")); // b
console.log(growKey(with6Items)("ab")); // (empty string)
console.log(growKey(with6Items)("abb")); // a
console.log(growKey(with6Items)("f")); // ood
console.log(growKey(with6Items)("abo")); // riginal
console.log(growPrefix(with6Items)("a")); // b
console.log(growPrefix(with6Items)("ab")); // (empty string)
console.log(growPrefix(with6Items)("abb")); // a
console.log(growPrefix(with6Items)("f")); // ood
console.log(growPrefix(with6Items)("abo")); // riginal
// suggest (also for auto-complete)
console.log(suggest(with8Items)("a")(3)); // 'ab', 'abba', 'aboriginal'