将min命令映射到haskell中的多级列表

plu*_*uke 3 haskell functional-programming

我想在一组列表中找到最小值

map min [[1, 3], [2, 7],[9, 6]]
Run Code Online (Sandbox Code Playgroud)

我想要这个输出

[[1],[2],[6]]
Run Code Online (Sandbox Code Playgroud)

它给出了错误:

* No instance for (Show ([Integer] -> [Integer]))
arising from a use of `print'
(maybe you haven't applied a function to enough arguments?)
* In a stmt of an interactive GHCi command: print it
Run Code Online (Sandbox Code Playgroud)

Wil*_*sem 7

min :: Ord a => a -> a -> a处理两个项目以返回两者中的最小值。您可能正在寻找minimum :: (Foldable f, Ord a) => f a -> a

Prelude> map minimum [[1, 3], [2, 7],[9, 6]]
[1,2,6]
Run Code Online (Sandbox Code Playgroud)

在这里,这些项没有包装在单独的子列表中,但这只会导致(不必要的)额外的间接层。