TITLE: Haskell print array 2 or 3 dim
data MyX = MyX {name00_ :: String, age00_ :: Int} deriving (Show, Eq)
let s = take 100 $ repeat $ MyR "David"
-- ar <- DAO.newListArray ((0, 0, 0), (2, 3, 4)) s :: IO (IOArray (Int, Int, Int) MyR)
ar <- DAO.newListArray ((0, 0), (2, 3)) s :: IO (IOArray (Int, Int) MyR)
b <- getBounds ar
let lv = map (^..each) [fst b, snd b]
let lw = let x0 = head lv
x1 = last lv
xt = map (+1) $ x1 - x0
in tail xt
lv <- getAssocs ar
case len lw of
v | v == 2 -> do
pp "3 dim"
let lt = partList (head lw) $ partList (last lw) lv
mapM_ (\x -> do printMat x; fw "";) $ (map . map . map) snd lt
| v == 1 -> do
pp "2 dim"
let lt = partList (head lw) lv
printMat $ (map . map) snd lt
| otherwise -> do
pp "Unsupported dim"