Some are harder than others.
transpose :: [[a]] -> [[a]]This one was very hard indeed. After an entire day of bashing my head against the wall, I discovered a few things I didn't know about Haskell syntax before.
For instance, I used to think that at the end of the list, there were infinite : [] : [] : [] and so you go because if xs in (x : xs) could be infinite, why not : []?
Things I try to do for each of the functions I'm rewriting:
- I try to figure out the type on my own. So far, this one seems to go fine.
- I write it / bash my head against the wall.
- I import QuickCheck, and write a test to compare my version versus the Data.List version. e.g.
- testx a l = x a l === Data.List.x a l
- It is incredibly handy not to have to write something to test your functions on. When I was learning C, that was rather annoying.