View difference between Paste ID: 12XbBh9Q and 4GFX3zri
SHOW: | | - or go back to the newest paste.
1-
def flip(k:Any,v:Any):(Any,Any) = (v,k)
1+
def flip[A,B]: (A,B) => (B,A) = { case (k,v) => (v,k) }
2
3
val word_count = words map {sentWords => sentWords map (w => (w.toLowerCase,1))} flatMap {ws => ws} reduceByKey (_ + _) map { case (k,v) => (v,k) } //works ok
4
5
val word_count = words map {sentWords => sentWords map (w => (w.toLowerCase,1))} flatMap {ws => ws} reduceByKey (_ + _) map flip //doesnt work