functional programming - Use map function to transform two seqs into one. Scala -


in clojure have map function can provide function , 2 collections

(map + [1 2 ] [4 5 ]) ;;=> (5 7 ) 

is there similar in scala?

i tried comprehension got 4 combinations.

if there way comprehension, better because have filtering in future/

you can use .zip first combine 2 collections one, map:

seq1.zip(seq2).map { case (x, y) => x + y } 

i don't think it's possible for-comprehension. can filtering call .filter or .filternot well.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -