Advertisement
Guest User

Untitled

a guest
Aug 10th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.26 KB | None | 0 0
  1.   def weirdFold[T,B](s:List[T], init:B, f:(T,List[T], B) => (T,B)) = {
  2.     val v = s.toVector
  3.     val (nv, nb, _) = v.foldLeft((v, init, 0)) { case ((ts, b, i), t) =>
  4.       val (newT, newB) = f(t, s, b)
  5.       (ts.updated(i, newT), newB, i+1)
  6.     }
  7.     (nv.toList, nb)
  8.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement