Purely Functional Data Structures in Clojure: Leftist Heaps by Leonardo Borges.
From the post:
Last year I started reading a book called Purely Functional Data Structures. It’s a fascinating book and if you’ve ever wondered how Clojure’s persistent data structures work, it’s mandatory reading.
However, all code samples in the book are written in ML – with Haskell versions in the end of the book. This means I got stuck in Chapter 3, where the ML snippets start.
I had no clue about Haskell’s – much less ML’s! – syntax and I was finding it very difficult to follow along. What I did notice is that their syntaxes are not so different from each other.
So I put the book down and read Learn You a Haskell For Great Good! with the hopes that learning more about haskell’s syntax – in particular, learning how to read its type signatures – would help me get going with Puretly Functional Data Structures.
Luckily, I was right – and I recommend you do the same if you’re not familiar with either of those languages. Learn You a Haskell For Great Good! is a great book and I got a lot out of it. My series on Monads is a product of reading it.
Enough background though.
The purpose of this post is two-fold: One is to share the github repository I created and that will contain the Clojure versions of the data structures in the book as well as most solutions to the exercises – or at least as many as my time-poor life allows me to implement.
The other is to walk you through some of the code and get a discussion going. Hopefully we will all learn something – as I certainly have when implementing these. Today, we’ll start with Leftist Heaps.
This sounds like a wonderful resource in the making!
I first saw this at Christophe Lalanne’s A bag of tweets / February 2013.