haskell - Pretty Printing list of lists -
i have list of lists:
[[5,1,0,0,5,5,0,0],[0,0,1,4,2,0,6,1],[1,1,6,3,0,1,0,0],[1,5,0,0,0,1,1,6]]
and string "wxyz"
i have: 1)
w: 5 1 0 0 5 5 0 0 x: 0 0 1 4 2 0 6 1 y: 1 1 6 3 0 1 0 0 z: 1 5 0 0 0 1 1 6
i wrote:
f c xs = putstrln (c : ':' : ' ' : concat (intersperse " " $ map show xs))
to write 1 line
and 2)
g xxs c = mapm_ (f c) xxs
how can modify 2) loop through string "wxyz" in order have 1) ?
instead of mapm_
, can use zipwithm_
control.monad
:
g xss cs = zipwithm_ f cs xss
or, if change order of arguments in either f
or g
match, can less "points":
g = zipwithm_ f
also, concat (intersperse " " ...)
otherwise known unwords ...
.
Comments
Post a Comment