fork download
  1. import Data.Array (Array, (!), (//), bounds, listArray)
  2.  
  3. -- matrixes :: Int -> [[(Int, Int)]]
  4. matrixes n = go 1 . listArray (1, 9) . repeat $ 9
  5. where
  6. go :: Int -> Array Int Int -> [[Int]]
  7. go i rs = let maxIndex = snd (bounds rs)
  8. r = rs ! i
  9. in if i > maxIndex then []
  10. else if r == 0 then go (i + 1) rs
  11. else map (i :) (go 1 (rs // [(i, (rs ! i) - 1)])) ++ go (i + 1) rs
  12.  
  13.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:1:1: error:
    The IO action ‘main’ is not defined in module ‘Main’
  |
1 | import Data.Array  (Array, (!), (//), bounds, listArray)
  | ^
stdout
Standard output is empty