I'm trying to make compact update rules for a list of tuples.
This is an example of an update rule:
rule1: [(a,b) | (a,b) <- zip [1..3] [2..4]]
λ:[(1,2),(2,3),(3,4)]
What I want:
rule2: [(a,b) (b,a) | (a,b) <- zip [1..3] [2..4]]
λ(expected):[(1,2),(2,1),(2,3),(3,2),(3,4),(4,3)]
Is something like this possible in Haskell's list comprehension?
A possible solution that works, but I find it a bit ugly is:
concat [[(a,b),(b,a)] | (a,b) <- zip [1..3] [2..4]]
λ: [(1,2),(2,1),(2,3),(3,2),(3,4),(4,3)]