June 2007 Archives

Functional Programming Hacks for Ruby

| 1 Comment

I've been noodling around with Proc, Method, UnboundMethod and Symbol, and have come up with the following utilities for:

  • function composition
  • function memoization
  • function currying
  • symbol-to-method conversion (different than Symbol.to_proc)

I don't claim that any of this is actually useful. But it might be mind-expanding or character building.

I'm relatively new to Ruby, so comments from more experienced rubyists are more than welcome.

The code follows...

Books

Comprehensive coverage of Ruby 1.8 and 1.9

"The New Most Important Ruby Book"
Peter Cooper,
rubyinside.com

Completely updated for Ajax and Web 2.0

"A must-have reference"
Brendan Eich,
creator of JavaScript

The classic Java quick-reference