Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个类型列表的列表:我可以旋转它(在某种意义上),以便:
[[a,b], [[b,d], [c,d]] => [a,c]]
对于任何尺寸列表?或者,如果对于任意大小的列表不可能,仅针对大小为 6x6 的列表
以下内容应为您提供所需的输出:
import Data.List (transpose) rotate :: [[a]] -> [[a]] rotate = reverse . transpose
测试:
*Main> rotate [[1,2],[3,4]] [[2,4],[1,3]] *Main> rotate [[1,2,3],[4,5,6],[7,8,9]] [[3,6,9],[2,5,8],[1,4,7]]
就胡歌吧!
[[a]] -> [[a]]