How do I create multiple generators for list recognition in F #?

I'm trying to write something like this

[(x,y)|x<- [1,2,3], y <- [’a’,’b’]]
 => [(1,’a’),(1,’b’),(2,’a’),(2,’b’),(3,’a’),(3,’b’)]
+3
source share
3 answers
[for x in [1;2;3] do
 for y in ['a';'b'] do
 yield x,y]
+6
source

just another interesting way

[1;2;3] |> List.map ( fun X -> ['a';'b'] |> List.map (fun A -> X,A) )
+2
source

equivalent to F #.

List.zip [1;2;3] ['a';'b';'c']
-2
source

All Articles