cphaskell
public text v1 · immutablerunl2 t =
do
put 0
t' <- l2 t
return t'
l2 :: Tree a -> State Int (Tree (a,Int))
l2 Empty = return Empty
l2 (Node e t1 t2) =
do
i <- get
put (i+1)
t1' <- l2 t1
t2' <- l2 t2
return (Node (e,i) t1' t2')