diff options
Diffstat (limited to 'lib/Data/Packed/Matrix.hs')
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 8 |
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 | ||
197 | this 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 | -} | ||
196 | format :: (Field t) => String -> (t -> String) -> Matrix t -> String | 204 | format :: (Field t) => String -> (t -> String) -> Matrix t -> String |
197 | format sep f m = dsp' sep . map (map f) . toLists $ m | 205 | format sep f m = dsp' sep . map (map f) . toLists $ m |
198 | 206 | ||