Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def weirdFold[T,B](s:List[T], init:B, f:(T,List[T], B) => (T,B)) = {
- val v = s.toVector
- val (nv, nb, _) = v.foldLeft((v, init, 0)) { case ((ts, b, i), t) =>
- val (newT, newB) = f(t, s, b)
- (ts.updated(i, newT), newB, i+1)
- }
- (nv.toList, nb)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement