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.

Programming, Ruby | Comments | Trackback

Leave a Reply

  1.  
  2.  
  3.  
  4. XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
You can keep track of new comments to this post with the comments feed.

Recent Posts

Blogroll

Siti amici

Misc

Recent Comments

Categories

Enrico Franchi graduated in Maths and Computer Science and is now studying for a Computet Science MSc (though because of italian bureaucracy that very course is to be cancelled).

RiK0's Tech Temple is using WP-Gravatar