✓
Passing This code compiles and runs correctly.
Code
// PIN (collapse-recursion pass, WAY-TWO leg): binom's double self-call with
// n-1 on both calls and k/k-1 split admits B2 — factorial-quotient product
// for 0 <= k <= n, residual otherwise. C(10,5) = 252 proves semantics.
import std/io
pub tor binom { n: i64, k: i64 } -> i64
binom = if(k == 0)
| then -> 1
| else |> if(k == n)
| then -> 1
| else |> binom(n: n - 1, k: k - 1): a |> binom(n: n - 1, k): b -> a + b
binom(n: 10, k: 5): r |> std/io:print.ln("{{ r:d }}")
Actual
252
Expected output
252
Flows
subflow ~binom click a branch to expand · @labels scroll to their anchor
if (k == 0)
flow ~binom click a branch to expand · @labels scroll to their anchor
binom (n: 10, k: 5)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# Pin: collapse-recursion fires B2 on binom. Marker __koru_collapse_b2_binom
# plus the factorial-quotient product fingerprint (__div@/mul chain).
set -e
if ! grep -q '__koru_collapse_b2_binom' output_emitted.zig; then
echo "FAIL: __koru_collapse_b2_binom marker absent — collapse pass did not fire on binom"
exit 1
fi