data Flip = H | T;
data Flips = Cons Flip Flips;
data Unit = unit;
extern tick: Unit;
define flips = Cons (sample uniform) flips;
define search = \fs: Flips. let _ = tick in
case fs of | Cons f1 fs1 -> if f1 == T then search fs1 else
case fs1 of | Cons f2 fs2 -> if f2 == H then search (Cons H fs2) else
case fs2 of | Cons f3 fs3 -> if f3 == T then search (Cons T (Cons T fs3)) else let _ = tick in tick;
search flips
From @ccshan:
Output: