Scala method to combine each element of an iterable with each element of another? -
if have this:
val = array("a ","b ","c ") val b = array("x","y")
i know if such method exists let me traverse first collection, , each of it's elements, walk entire second collection. example, if take array a
, have a,x
,a,y
,b,x
,b,y
,c,x
,c,y
. know of zip i've seen works on collections of same sizes, , associates elements same positions.
i'm not sure of "method", can expressed nested/compound for
:
val = array("a ","b ","c ") val b = array("x","y") (a_ <- a; b_ <- b) yield (a_, b_) res0: array[(java.lang.string, java.lang.string)] = array((a ,x), (a ,y), (b ,x), (b ,y), (c ,x), (c ,y))
happy coding.
Comments
Post a Comment