2014-09-17 2 views
6

scanscanLeft의 차이점은 무엇입니까? 예컨대 Scala에서 scan과 scanLeft의 차이점

,

(1 to 3).scan(10)(_-_) 
res: Vector(10, 9, 7, 4) 

(1 to 3).scanLeft(10)(_-_) 
res: Vector(10, 9, 7, 4) 

기본적

(1 to 3).scanRight(10)(_-_) 
res: Vector(-8, 9, -7, 10) 

답변

5
(1 to 3).par.scanLeft(10)(_-_) 
res: scala.collection.parallel.immutable.ParSeq[Int] = ParVector(10, 9, 7, 4) 

(1 to 3).par.scanRight(10)(_-_) 
res: scala.collection.parallel.immutable.ParSeq[Int] = ParVector(-8, 9, -7, 10) 

(1 to 3).par.scan(10)(_-_) 
res: scala.collection.parallel.immutable.ParSeq[Int] = ParVector(10, 9, -1, -4) 

달리 명확하게, 동일한 결과를 제공하는, 그것의 통과 가능한 구현에 따라 달라 scan* (또는 fold*) 실행됩니다.