Feeds:
Posts
Comments

Posts Tagged ‘Ruby’

SDBM

I’ve been a bit slow in my learning of Ruby. This time around I’ve re-written Ozan Yigit’s ndbm clone: sdbm.

I’ve cheated a bit. My general plan has been to pick things up through re-writing bits of existing code in Ruby: but to do them from memory (swotting up if necessary) rather than translate them directly. In this particular case it was convenient (for testing) to ensure that my implementation produced files that were bit-for-bit identical to those produced by the original (as incorporated into Perl). So, to avoid incompatibilities, I wrote down the string hash algorithm and the block sizes used for reading and writing the files. It was only a tiny cheat.

(more…)

Read Full Post »

This is the first step in the Burrows-Wheeler (bzip) compression algorithm. It doesn’t compress anything in itself, but re-orders the characters of the input in such a way that they will then be easy to compress:
(more…)

Read Full Post »

I thought I’d have a crack at learning Ruby. Strictly speaking this isn’t my first encounter, and so my title isn’t quite true, since a few years ago I did work through the “Rolling with Ruby on Rails” tutorial on the O’Reilly site. But as I was just copying and pasting code from a website, that doesn’t really count. (My opinion of Rails at the time was that barring some quibbles about the JSP-like HTML generation it seemed to be very good for the sort of thing it was aimed at, but that I was very happy not to be doing that sort of thing for a living.)

I’ve decided not to learn the language by buying a book or working through tutorials or suchlike. Instead, the plan is just to re-write tiny programs that I find interesting for any reason, relying on nothing much but whatever online reference documentation I can find together with my acquaintance with Perl and Python. This isn’t likely to be the best way of learning, but I want to see how far I can get with it.

(more…)

Read Full Post »