difference between foldLeft and reduceLeft in Scala

后端 未结 7 2019
野性不改
野性不改 2020-12-12 08:49

I have learned the basic difference between foldLeft and reduceLeft

foldLeft:

  • initial value has to be passed
7条回答
  •  隐瞒了意图╮
    2020-12-12 09:38

    To really understand what are you doing with fold/reduce, check this: http://wiki.tcl.tk/17983 very good explanation. once you get the concept of fold, reduce will come together with the answer above: list.tail.foldLeft(list.head)(_)

提交回复
热议问题