fork(1) download
  1. dim :: [[a]] -> (Int, Int)
  2. dim ls = let x = length ls
  3. ys = map length ls
  4. in case ys of
  5. h:t -> if all (==h) t then (x, h) else (0, 0)
  6. [] -> (0, 0)
  7.  
  8. main = do
  9. print $ dim [[1, 1], [1, 1]]
  10. print $ dim [[1, 1], [2, 2, 2]]
Success #stdin #stdout 0.01s 3584KB
stdin
Standard input is empty
stdout
(2,2)
(0,0)