Tuesday 19 August 2014

Data.List

I'm reading through Learn You a Haskell's section on Data.List at the moment, and fiddling around with rewriting some of the functions. 

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: 

  1. I try to figure out the type on my own. So far, this one seems to go fine.
  2. I write it / bash my head against the wall. 
  3. 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. 

Friday 15 August 2014

Wednesday 6 August 2014

Programming in Haskell

This is the main textbook I'm using at the moment, though it's a little older. Seems to be the only Haskell textbook I have found targeted at people who haven't programmed before.

I'm nearly half way through. I would like exercises that are a bit meatier, a la the famed SICP, but otherwise it is pretty good. I don't think I have made so deep into any other programming textbook yet.
I hope to finish this one before the end of the month. Most of the chapters have taken me about 2 days so far, and there's only 13 chapters.

The Programmer Bear approves of what I'm learning, and has been supplementing my education with bits and bobs, like teaching me how to write tests for my exercises.

Switching Back to Vim

Exactly like it says on the cover.

The Ctrl + Alt key thing got too much for me pretty quickly. How do people who use emacs not get RSIs in their little fingers?

On the bright side, this is spurring me on to learn the Vim shortcuts more quickly.

Sunday 3 August 2014

Rewriting Library Functions

I've been busily rewriting a number of library functions at the behest of the PB.

(Formerly known as the Programmer Boyfriend, he shall henceforth be known as Programmer Bear. T-shirts and other goodies to come.)

Most of the functions I've been writing are meant to be applied to lists, such as qsort, drop and take, and are mostly recursive.

Overall, I find these exercises to be rather useful. They help me understand how these functions work, and give me tiny glimpses into 'real' programming.