summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Matrix.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed/Matrix.hs')
-rw-r--r--lib/Data/Packed/Matrix.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs
index e94d038..a705975 100644
--- a/lib/Data/Packed/Matrix.hs
+++ b/lib/Data/Packed/Matrix.hs
@@ -193,6 +193,14 @@ dsp' sep as = unlines . map unwords' $ transpose mtp where
193 pad n str = replicate (n - length str) ' ' ++ str 193 pad n str = replicate (n - length str) ' ' ++ str
194 unwords' = concat . intersperse sep 194 unwords' = concat . intersperse sep
195 195
196{- | Creates a string from a matrix given a separator and a function to show each entry. Using
197this function the user can easily define any desired display function:
198
199@import Text.Printf(printf)@
200
201@disp = putStrLn . format \" \" (printf \"%.2f\")@
202
203-}
196format :: (Field t) => String -> (t -> String) -> Matrix t -> String 204format :: (Field t) => String -> (t -> String) -> Matrix t -> String
197format sep f m = dsp' sep . map (map f) . toLists $ m 205format sep f m = dsp' sep . map (map f) . toLists $ m
198 206