8/31/2005

getting started with Haskell

I’ve started working through Yet Another Haskell Tutorial to teach myself some haskell. I’m not too far into it, but it’s making sense so far—none of the mind-bending strangeness that I keep hearing about. Nothing that makes me want to give up Ruby either.

Here’s my version of a recursive multiplication by addition function from one of the exercises:




mult a 1 = a
mult a n = a + mult a (n -1)




8/15/2005

Not nearly a Ruby master, but I'm working on it.

One of the things of been doing lately is writing about Ruby. An article of mine was released on IBM’s DeveloperWorks site last week (yay!), and just got linked from OS News (http://www.osnews.com/story.php?news_id=11574) which is pretty awesome too.

8/05/2005

more ruby

today, i needed a class for handling IP addresses for hosts and the IPAddr class from the standard library didn’t quite do everything I needed, so I ended up writing one for myself. Now, when people do data entry into my hosts database I can keep them from entering all kinds of hokey, bad data:

here’s some trimmed output from irb:




host = IP_Addr.new(‘192.168.1.0’, ‘255.255.255.0’)
RuntimeError: bad ip address, can’t use network address
host = IP_Addr.new(‘192.168.1.255’, ‘255.255.255.0’)
RuntimeError: bad ip address, can’t use broadcast address
host = IP_Addr.new(‘192.168.1.253’, ‘255.255.255.0’)
host.network
=> “192.168.1.0”
host.broadcast
=> “192.168.1.255”




now, I can count on my db not having network or broadcast addresses (or other invalid addresses that I’m checking for), and I can build dhcp and dns config files automaticly.