I\'ve come across the problem of maintaining a state throughout a map operation several times. Imagine the following task:
Given a List[Int], map each element to the
I like to fold around just like everybody else, but a less FP answer is very concise and readable:
a.map{var v=0; x=>{v+=x; v}}