fork download
  1. import Data.List
  2.  
  3. testMatrix :: [[Int]]
  4. testMatrix = [[ 1, 2, 3,4],
  5. [12,13,14,5],
  6. [11,16,15,6],
  7. [10, 9, 8,7]]
  8.  
  9. main :: IO ()
  10. main = do
  11. let clockwise [] = []
  12. clockwise (h:t) = h++(clockwise $ reverse $ transpose t)
  13. contraclockwise = clockwise . transpose
  14. print $ zipWith (*) (clockwise testMatrix) (contraclockwise testMatrix)
  15.  
Success #stdin #stdout 0s 4448KB
stdin
Standard input is empty
stdout
[1,24,33,40,45,48,49,48,45,40,33,24,169,224,225,224]