Dear list,
I'm currently engaged in an attempt to wrap my head around type
arithmetic. To make sure that I've understood, I plan to write a few
operations on matrices a la Oleg's Number Parameterised Types. Before
I get down to it, I've been making sure I know how to implement the
operati
On Thu, 15 Jun 2006, Thomas Sutton wrote:
Today I've been looking at rotating matrices, i.e: taking a column-wise
matrix and making it row-wise and, in the process, swapping the dimensions
(thus a 3*2 matrix becomes a 2*3 matrix).
You mean 'matrix transposition' which is available as Data.Li
Thomas,
> rotate' :: [[a]] -> [[a]]
> rotate' [] = []
> rotate' xs = (map (head) xs ):(rotate' $ filter (not . null) $
map (tail) xs)
which seems to work just fine. While this solution is adequate (it
seems to work for infinite structures as well, which is good), I
originally set out to
On 15/06/06, Stefan Holdermans <[EMAIL PROTECTED]> wrote:
transpose = foldr (zipWith (:)) (repeat [])
While one-liners like this are very pretty, it's worth thinking about
how they work:
1. (:) takes an element and a list and prepends that element to the list.
2. zipWith (:) takes a list of