Design decisions

81. std.slope.{Concave, Convex}: the slope trick as a library type (2026-11-21)

Decision. A concave function on integer points is f(lo) plus its falling slopes in a LazyTreap; max_convolve merges slopes, add_quadratic(q) adds a rank-indexed progression read from three values of q (a fourth and the sign of q'' are checked), and at/max read it back. Convex wraps a negated Concave, one design for both. cf2084g2 drops its hand-written treap lambdas for it. Why. The apply/compose/split lambdas were the slope trick itself, which every slope-trick port would rewrite; the operations name the recurrence (dp(c) = max(dp(c), dp(c - 1)) is max_convolve(flat(0..=1))). Cost. +3.3 KB emitted in cf2084g2 (the struct and to_list), runtime within 1.1x of the bare treap and 0.8x the original. Reversal. Delete stdlib/slope.cp and restore the LazyTreap port from history; nothing else depends on it.