Relative Content

Tag Archive for scala

multiple pattern matching on iteration

val subjectpairs = IndexedSeq((8,0),(3,4),(0,9),(6,1)) val priors = subjectpairs.map { case( f,_) => f}.filter{ _ >0.0} val posts = subjectpairs.map { case( _,l) => l}.filter{ _ >0.0} This creates 2 sequences from the first , with the first and second members of tuples as non-zero respectively. However , this needs 2 iterations of the source sequence […]

multiple pattern matching on iteration

val subjectpairs = IndexedSeq((8,0),(3,4),(0,9),(6,1)) val priors = subjectpairs.map { case( f,_) => f}.filter{ _ >0.0} val posts = subjectpairs.map { case( _,l) => l}.filter{ _ >0.0} This creates 2 sequences from the first , with the first and second members of tuples as non-zero respectively. However , this needs 2 iterations of the source sequence […]