A Big Smile ... Ruby and Erlang

A big smile appeared on my face tonight after typing the following: -module(math1). -export([factorial/1]). factorial(0) -> 1; factorial(N) -> N * factorial(N-1). def factorial(n) return 1 if n == 0 n * factorial(n-1) end Maybe not so obvious. But check this out: -module(temp). -export([convert/2]). convert({fahrenheit, Temp}, celsius) -> {celsius, 5 * (Temp -32) / 9}; convert({celsius, Temp}, fahrenheit) -> {fahrenheit, 32 + Temp * 9 / 5}; convert({reaumur, Temp}, celsius) -> {celsius, 10 * Temp / 8}; convert({celsius, Temp}, reaumur) -> {reaumur, 8 * Temp / 10}; convert({X, _}, Y) -> {cannot,convert,X,to,Y}....

August 25, 2006 · 3 min · Justin Langhorst

Adding to the Ruby Logger

I’ve been working on some new code at work for a new install. Unfortunately, I’m unable to use the new framework just yet (mainly because it’s not complete), and I needed a workaround for the Ruby Logger to be able to accept .trace calls (we usually use Log4r. Here’s my workaround: require 'logger' # Redefine the Logger to allow for TRACE calls. class Logger module Severity TRACE = -1 end def trace?...

June 23, 2006 · 1 min · Justin Langhorst