Add mapAccumL and mapAccumR. Closes #632.

Reviewed by @tolmasky.