[Haskell-cafe] How to devide matrix into small blocks
Janis Voigtlaender
voigt at tcs.inf.tu-dresden.de
Thu Jun 14 03:42:38 EDT 2007
L.Guo wrote:
> I have wrote the target function like this, and tested.
>
> mkBlocks (w,h) = map concat . concat . transpose . chop h . map (chop w)
I don't understand how this relates to your original problem
description. But then, again, I probably did not understand that one too
well.
> This is not a homework, though likely to be one.
No offense meant, of course.
Anyway, as a challenge to others on the list: write a one-liner that
splits an "image" like ["abcd","efgh","ijkl","mnop"], interpreted as
abcd
efgh
ijkl
mnop
into the list of images:
[
ab
ef
,
cd
gh
,
ij
mn
,
kl
op
]
for (w,h)=(2,2), into:
[
a
e
,
b
f
,
c
g
,
d
h
,
i
m
,
j
n
,
k
o
,
l
p
]
for (w,h)=(1,2), and so on.
(Where an image like
ab
ef
is represented as ["ab","ef"].)
Have fun, Janis.
--
Dr. Janis Voigtlaender
http://wwwtcs.inf.tu-dresden.de/~voigt/
mailto:voigt at tcs.inf.tu-dresden.de
More information about the Haskell-Cafe
mailing list