All combinations of elements of two lists in Haskell

前端 未结 5 1088
情歌与酒
情歌与酒 2020-12-30 03:42

Given two lists, [a, b] and [c, d], I\'d like to get the following result:

[(a,c), (a,d), (b         


        
5条回答
  •  失恋的感觉
    2020-12-30 04:23

    [ (x,y) | x<-[a,b], y<-[c,d] ]
    

    This doesn't really require any further explanation, does it?

提交回复
热议问题