ocaml: phase 5.1 trie.ml baseline (prefix tree, 6/9 word lookups match)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
Mutable-record trie with linked-list children:
type trie = {
mutable terminal : bool;
mutable children : (char * trie) list
}
Insert {cat, car, card, cart, dog, doge}; lookup 9 words. Hits are
exactly the inserted set: cat, car, card, cart, dog, doge = 6.
Misses: ca (prefix not terminal), dogs (extends 'dog' but no 'dogs'
node), x (no path).
Tests:
- recursive type definition with self-referential field
- mutable record fields with .field <- v
- Option pattern matching (Some / None)
- tuple-cons pattern (k, v) :: rest
146 baseline programs total.
This commit is contained in:
@@ -407,6 +407,16 @@ _Newest first._
|
||||
binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree *
|
||||
'a tree`) with insert + in-order traversal. Tests parametric ADT,
|
||||
recursive match, List.append, List.fold_left.
|
||||
- 2026-05-10 Phase 5.1 — trie.ml baseline (prefix tree, 6 of 9
|
||||
word lookups match). Mutable record `{ terminal; children }` with
|
||||
`children : (char * trie) list`; insert recurses down character
|
||||
by character, mutating children list when a path is missing.
|
||||
Insert {cat, car, card, cart, dog, doge}; lookup {cat, car, ca,
|
||||
card, cart, dog, doge, dogs, x}. The 6 hits are exactly the
|
||||
inserted words; "ca", "dogs", "x" miss.
|
||||
Tests recursive type definition with self-reference, mutable
|
||||
records, `match … | Some / None` over option, pattern with
|
||||
`(k, v) :: rest` tuple destructuring. 146 baseline programs total.
|
||||
- 2026-05-10 Phase 5.1 — count_inversions.ml baseline (count
|
||||
inversions of [|8;4;2;1;3;5;7;6|] = 12, via merge-sort). Modified
|
||||
merge sort: when right element is taken, accumulate `mid - i + 1`
|
||||
|
||||
Reference in New Issue
Block a user