http://www.artima.com//rubycs/articles/patterns_sexp_dsls.html
Haskellっぽいパターンマッチを行うモジュール.おもしろいんだがあまり使い勝手は良くなかった.
require 'rubygems' require 'multi' multi(:fact, 0) { 1 } multi(:fact, Integer) { |n| n * fact(n-1) } for i in (0..5) puts "fact(#{i}) ==> #{fact(i)}" end
$ruby fact.rb fact(0) ==> 1 fact(1) ==> 1 fact(2) ==> 2 fact(3) ==> 6 fact(4) ==> 24 fact(5) ==> 120