let
acc1 acc f a =
let
(b, side_effect) = f a
in
acc := side_effect :: !acc; b