CPS版 mapAccumL
code:CPS.hs
mapAccumLcps :: (a -> b -> (a -> c -> r) -> r)
-> a
->
b
-> (a ->
c
-> r)
-> r
mapAccumLcps phi a0 [] k = k a0 []
mapAccumLcps phi a0 (b:bs) k
= phi a0 b (\ a c -> mapAccumLcc phi a bs (\ a' cs -> k a' (c:cs)))