Cartesian product of two lists

后端 未结 3 925
一整个雨季
一整个雨季 2020-11-29 06:34

Given a map where a digit is associated to several characters

scala> val conversion = Map(\"0\" -> List(\"A\", \"B\"), \"1\" -> List(\"C\", \"D\"))
         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 07:20

    I just did that as follows and it works

        def cross(a:IndexedSeq[Tree], b:IndexedSeq[Tree]) = {
            a.map (p => b.map( o => (p,o))).flatten
        }
    

    Don't see the $Tree type that am dealing it works for arbitrary collections too..

提交回复
热议问题