Re: [Haskell-cafe] How to devide matrix into small blocks

2007-06-15 Thread Janis Voigtlaender
Daniel Fischer wrote: What about blocks w h = concatMap transpose . map (map (chop w)) . chop h Seems right. I arrived at something else: divide w h ls = concatMap (foldr (zipWith (:) . chop w) (repeat [])) (chop h ls) That uses fewer intermediate lists, and indeed

Re: [Haskell-cafe] How to devide matrix into small blocks

2007-06-14 Thread Janis Voigtlaender
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

Re: [Haskell-cafe] How to devide matrix into small blocks

2007-06-14 Thread L.Guo
-in-block]], and also, is close to my future purpose. Thanks. -- L.Guo 2007-06-14 - From: Janis Voigtlaender At: 2007-06-14 15:42:40 Subject: Re: [Haskell-cafe] How to devide matrix into small

Re: [Haskell-cafe] How to devide matrix into small blocks

2007-06-14 Thread Henning Thielemann
On Thu, 14 Jun 2007, Janis Voigtlaender wrote: 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 ] It's just an

Re: [Haskell-cafe] How to devide matrix into small blocks

2007-06-14 Thread Henning Thielemann
On Thu, 14 Jun 2007, L.Guo wrote: About the data. The whole image is of type [[a]], and after being devided, it is also [[a]]. I would store an image in an (Array (Int,Int)). This is not only more efficient, but also ensures statically that the image data is rectangular. I assume that you do

Re: [Haskell-cafe] How to devide matrix into small blocks

2007-06-14 Thread Janis Voigtlaender
Henning Thielemann wrote: On Thu, 14 Jun 2007, Janis Voigtlaender wrote: 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 ] It's

Re: [Haskell-cafe] How to devide matrix into small blocks

2007-06-14 Thread Daniel Fischer
What about blocks w h = concatMap transpose . map (map (chop w)) . chop h ? @L. Guo: map concat . blocks w h is what you want. Cheers, Daniel Am Donnerstag, 14. Juni 2007 09:42 schrieb Janis Voigtlaender: Anyway, as a challenge to others on the list: write a one-liner that splits an image

Re: [Haskell-cafe] How to devide matrix into small blocks

2007-06-13 Thread Janis Voigtlaender
L.Guo wrote: Hi all: I already have one matrix of type [[a]] to store one image. What I want to do is to devide the image into severial small blocks in same size. In the sense of dividing an image like abcd efgh ijkl mnop into the sequence of images [ ab ef , cd gh , ij mn , kl op ]

Re: [Haskell-cafe] How to devide matrix into small blocks

2007-06-13 Thread Janis Voigtlaender
Henning Thielemann wrote: On Wed, 13 Jun 2007, L.Guo wrote: I already have one matrix of type [[a]] to store one image. What I want to do is to devide the image into severial small blocks in same size. To do that, I wrote this tool function. chop :: Int - [a] - [[a]] chop _ [] = []

Re: [Haskell-cafe] How to devide matrix into small blocks

2007-06-13 Thread Henning Thielemann
On Wed, 13 Jun 2007, L.Guo wrote: I already have one matrix of type [[a]] to store one image. What I want to do is to devide the image into severial small blocks in same size. To do that, I wrote this tool function. chop :: Int - [a] - [[a]] chop _ [] = [] chop n ls = take n ls :

Re: [Haskell-cafe] How to devide matrix into small blocks

2007-06-13 Thread L.Guo
Hi, Henning Thielemann. Thanks for your help. That is usful. I have wrote the target function like this, and tested. mkBlocks (w,h) = map concat . concat . transpose . chop h . map (chop w) Hi, Dr. Janis Voigtlaender. This is not a homework, though likely to be one. I just use Haskell to

[Haskell-cafe] How to devide matrix into small blocks

2007-06-12 Thread L.Guo
Hi all: I already have one matrix of type [[a]] to store one image. What I want to do is to devide the image into severial small blocks in same size. To do that, I wrote this tool function. chop :: Int - [a] - [[a]] chop _ [] = [] chop n ls = take n ls : chop n (drop n ls) But I do not