Pattern Matching in Ruby
June 21st, 2006
Inspired by a discussion on the Italian Ruby mailing list, I decided to write (probably another) pattern matching implementation for ruby. In the short term I want to be able to define something like:
func :qsort, [] { [] }
func :qsort do | list |
qsort( list.select {|a| a < list[0]} ) +
list.select {|a| a == list[0]} +
qsort( list.select {|a| a > list[0]} )
end
and if I find time it could become even some kind of “declarative like” unification algorithm… who knows. The point is I don’t even know if I have enough time for the “toy” pattern matching.
Leave a Reply