// Benchmark: Closure creation and calls (measures closure overhead) // Tests: Closure capture, higher-order functions fn makeAdder(n: Int): fn(Int): Int = fn(x: Int): Int => x + n fn applyN(f: fn(Int): Int, x: Int, n: Int): Int = if n <= 0 then x else applyN(f, f(x), n - 1) // Create 1000 closures and apply them fn benchmark(count: Int): Int = if count <= 0 then 0 else { let adder = makeAdder(count) let result = applyN(adder, 0, 100) result + benchmark(count - 1) } let result = benchmark(1000)