Archive for August, 2007

Random pain in Haskell

Random numbers seem to be a bit of a pain in Haskell. Because they are not a “pure” function (they involve hooking up with a system or user-supplied random number generator) there is a little scaffolding involved. Also when the number comes back, it's wrapped in an IO Ref, making the whole of your function […]

More on Maybes and Haskell Ternary

I was playing with the Maybe type and realised that there are useful functions provided to play with these types. Then I realised that in my definition of ternary operator in haskell the definition of (!) > Nothing ! a = a > Just b ! _ = b was very similar to the predefined […]

The Red Black Moose

For some time I've been wanting to implement the Enfilade, a really cool data structure discovered by the Xanadu people among others. It's like a balanced tree, except that it's indexed relatively rather than absolutely – making it ideal for things like text editor buffers, as you can insert and delete with impunity, knowing that […]

Least common multiples – the scenic route

I've been back to Edinburgh for a family reunion and got to spend a morning with my dad who's a maths teacher by trade — I always thought he might be interested in haskell but never got the time to really look at some stuff in a bit of detail. I'd been pointed at Project […]