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

Managing users and groups from the OS X terminal

I was recently playing around with SaltStack and wanted to create a salt user and group to run the master. This led me to learn some basics of user and group management on OS X, and I thought I’d put them here to remember. FYI I did all this on Yosemite, but it seems like this is the way things have worked for a while, so it should work on just about any OS X system that’s still running I would think. No guarantees though.

Continue reading

Brew + encfs + osxfuse + Yosemite upgrade = problem

I finally pulled my finger out and updated to Yosemite yesterday. I probably don’t need any of the features, but I prefer the look. It also seems like a good idea to stay up to date for warranty purposes – I once got an out of warranty battery replacement 4 years after purchase because I was a good Apple kid and stayed up to date. Anyway, as with the update to Mavericks, I ran into a problem with EncFS not working.

Continue reading

Executing your code from Vim

My girlfriend is currently learning Python, and using Vim as her text editor (because she’s a boss). She told me this morning that she was quitting Vim to run her code each time she changed it, which was becoming annoying. I showed her a couple of methods to do this and thought I’d quickly document it for her and others. We both run Macs, and run Vim from Terminal/iTerm, but this should at least point you in the right direction if you’re running a different OS. Also, the examples below use Python, but should work equally well for similar scripting environments like Perl or Ruby.

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