ocaml: phase 5.1 powerset_target.ml baseline (subsets of {1..10} summing to 15 = 20)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
Recursive powerset construction by doubling:
let rec gen xs = match xs with
| [] -> [[]]
| h :: rest ->
let sub = gen rest in
sub @ List.map (fun s -> h :: s) sub
Enumerates all 2^10 = 1024 subsets, filters by sum:
count = |{ S ⊆ {1..10} | Σ S = 15 }| = 20
Examples: {1,2,3,4,5}, {2,3,4,6}, {1,4,10}, {7,8}, {6,9}, ...
Tests recursive subset construction via List.map + closures,
pattern matching with h :: rest, List.fold_left (+) 0 sum reduce,
exhaustive O(2^n * n) traversal.
172 baseline programs total.
This commit is contained in:
@@ -407,6 +407,15 @@ _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-11 Phase 5.1 — powerset_target.ml baseline (count subsets
|
||||
of {1..10} summing to 15 = 20). Generates the full 2^10 = 1024
|
||||
powerset by recursive doubling: `gen (h :: rest) = gen rest @
|
||||
map (cons h) (gen rest)`, then filters by sum. The 20 valid
|
||||
subsets include {1,2,3,4,5}, {2,3,4,6}, {1,4,10}, {7,8}, {6,9},
|
||||
etc. Tests recursive subset construction via List.map + closures,
|
||||
pattern matching with `h :: rest`, `List.fold_left (+) 0`
|
||||
one-line summary, exhaustive O(2^n · n) traversal. 172 baseline
|
||||
programs total.
|
||||
- 2026-05-11 Phase 5.1 — parser: top-level tuple patterns
|
||||
(`match e1, e2 with | p1, p2 -> …`). `parse-pattern` now collects
|
||||
comma-separated patterns into a `:ptuple`, mirroring the scrutinee
|
||||
|
||||
Reference in New Issue
Block a user