fold 및 foldLeft와 각각 reduce 및 reduceLeft 작업 방법을 이해하려고합니다. fold
이 foldLeft
대로 작동하지 않은 이유는 무엇입니까 예를스칼라 : fold vs foldLeft
scala> val r = List((ArrayBuffer(1, 2, 3, 4),10))
scala> r.foldLeft(ArrayBuffer(1,2,4,5))((x,y) => x -- y._1)
scala> res28: scala.collection.mutable.ArrayBuffer[Int] = ArrayBuffer(5)
scala> r.fold(ArrayBuffer(1,2,4,5))((x,y) => x -- y._1)
<console>:11: error: value _1 is not a member of Serializable with Equals
r.fold(ArrayBuffer(1,2,4,5))((x,y) => x -- y._1)
로 배와 foldLeft를 사용? Serializable with Equals
은 무엇입니까? fold를 이해하고 foldLeft는 매개 변수 제네릭 유형 측면에서 약간 다른 API 서명을가집니다. 제발 조언. 감사.
[fold fold와 foldLeft 또는 foldRight 사이의 차이점]? (http://stackoverflow.com/q/6253978) –
어떤 스칼라 버전입니까? –
내 스칼라 버전은 2.10.1입니다. – thlim