`
zyz611
  • 浏览: 91888 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

flodleft and fold right

 
阅读更多
def foldLeft[B](z: B)(op: (B, A) => B): B = {
    var result = z
    this.seq foreach (x => result = op(result, x))
    result
  }


def foldRight[B](z: B)(op: (A, B) => B): B =
    reversed.foldLeft(z)((x, y) => op(y, x))

参见:
http://blog.csdn.net/oopsoom/article/details/23447317
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics