Skip to content

Latest commit

 

History

History
8 lines (7 loc) · 248 Bytes

20-tight-recursion.md

File metadata and controls

8 lines (7 loc) · 248 Bytes

Exercise 20

prim c f 0 = c
prim c f n = f n (prim c f (n - 1))

The prim function passes c and f over and over despite they are loop invariants. Rewrite prim to use an inner function so they are kept in a closure instead.