Removing syntactic sugar: List comprehension in Haskell
问题 Can I unsugar list comprehension in this expression: [(i,j) | i <- [1..4], j <- [i+1..4]] This is the output: [(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)] How can I, with map, filter and so on, write that piece of code? edit Here an other: [(i,j,k) | i <- [1..6], j <- [i+1..6],k <- [j+1..6]] This is the output: [(1,2,3),(1,2,4),(1,2,5),(1,2,6),(1,3,4),(1,3,5),(1,3,6),(1,4,5),(1,4,6),(1,5,6),(2,3,4),(2,3,5),(2,3,6),(2,4,5),(2,4,6),(2,5,6),(3,4,5),(3,4,6),(3,5,6),(4,5,6)] 回答1: List comprehensions (in