O'Reilly logo
  • Dmitry Erokhin thinks this is interesting:

In the Scala standard library


Cover of Functional Programming in Scala


def foldLeftB(@deprecatedName('f) op: (B, A) => B): B = { var acc = z var these = this while (!these.isEmpty) { acc = op(acc, these.head) these = these.tail } acc }

def foldRightB(@deprecatedName('f) op: (A, B) => B): B = if (this.isEmpty) z else op(head, tail.foldRight(z)(op))