Dave Thomas's Kata One asks us to think about how one might implement pricing rules:
"Some things in supermarkets have simple prices: this can of beans costs $0.65. Other things have more complex
prices. For example:
o three for a dollar (so what?s the price if I buy 4, or 5?)
o $1.99/pound (so what does 4 ounces cost?)
o buy two, get one free (so does the third item have a price?)"
Functors provide one approach to this sort of problem, and in this example we'll demonstrate some simple cases.
See http://pragprog.com/pragdave/Practices/Kata/KataOne.rdoc,v for more information on this Kata.