Splitting list into a list of possible tuples

后端 未结 6 804
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 04:59

I need to split a list into a list of all possible tuples, but I\'m unsure of how to do so.

For example:

pairs [\"cat\",\"dog\",\"mouse\"]

6条回答
  •  無奈伤痛
    2020-11-28 05:47

    import Control.Applicative
    
    pairs xs = filter (uncurry (/=)) $ (,) <$> xs <*> xs
    

提交回复
热议问题