Clojure to Haskell: Composition

I’ve been playing with Clojure on and off for the past couple of years and have recently started to learn a little Haskell. I’ve read through a fair chunk of Learn you a Haskell and now I’m working through the CIS194 materials from UPenn after being introduced to them at the Brisbane Functional Programming Group. Side note: they’ve been doing their own presentations of the lectures and the videos are on their Vimeo channel (search for “Yorgey”).

While tackling the second week’s exercises I thought I could write a clean solution using point free syntax based on my experience with composition and partials in Clojure. I couldn’t. Unsurprisingly, Clojure’s lack of static typing gives it more room to move in these cases.

Continue reading

Counting change with Clojure: A dalliance in dynamic programming

I’m in the process of doing a great bioinformatics course on Coursera. One of the topics covers some dynamic programming, and uses making change as a toy problem to demonstrate the problem that dynamic programming solves, and how to implement it. I had fun remembering this stuff, and thought I’d do a little write up on how to solve a toy problem like this using Clojure. In the interest of not directly providing solutions to coursework, we’ll solve the related problem in SICP of counting change.

Continue reading

How to setup Mercurial on Windows for use with bitbucket over SSH

I enjoy making software. I also enjoy playing with the systems that support making software: for example source control, unit testing, continuous integration, issue tracking. As a result, I have wanted to set up my very own build server to manage personal projects for a while now.  As an intermediate step to building my own server, which looks to be a rather large undertaking, I have elected to use bitbucket. Using bitbucket not only provides me with these services while I work on developing my own, it should help to inform the choices I make regarding my own system.

For those who are new to bitbucket, as I am, it is an online service that provides, among other things, Mercurial hosting for your source code.  Its use of Mercurial, which is my current source control tool of choice, and its use of ssh keys for simple and secure communication are the two main reasons I have chosen it. Speaking of ssh keys for communication, there are two different ways to access your code once it is on bitbucket: via https using a username and password, or via SSH using public/private keys.  I’ve elected to use SSH because using https requires that you enter a password whenever you commit, and I’m too lazy for that. My personal philosophy is to automate as much as possible, and make things as easy as possible long term; even if that requires additional effort up front.

Continue reading

memcpy and memset

Now that I am back in the world of full-time work, I have begun to think more seriously about my goals. One of my life goals, which I have recently decided are a superset of career goals, is to learn as much as possible. I have also decided that learning as much as possible is also a member of my set of career goals. To alleviate any confusion, I drew a Venn diagram summarising the situation.

terrible Venn diagram of my life goals

As part of my new job, I am programming in C++ for a good part of each day. A consequence of this is that I am constantly learning new methods for writing and debugging C++ code, and programming in general. In an effort to document and share this knowledge, I’m going to start by telling you about memcpy and memset. memcpy and memset are two functions included in the C standard libraries.  memcpy is used to copy a block of memory from a source to a destination, and memset is similarly used to set a block of memory to a particular value.  While quite low level functions, these can both be very useful if speed is critical and you’re not working with higher level containers for whatever reason (yes, I know everyone says to use vectors if you’re not using straight C).

Continue reading

Floating Point Comparisons in C++

For the really geeky amongst you, here’s a pretty good article explaining some of the issues and approaches relating to floating point comparisons in C/C++.

On a side note, I’m almost done with my uni assignments for this semester. I’m hoping to post a few articles based on stuff I’ve encountered this semester once I get into exam period/holidays.

That is all.