On Tuesday 04 November 2008 06:03, Konrad Hinsen wrote: > ... > > As an illustration of the two approaches, consider a program to sort > data. In OOP, one would define an abstract class "comparable" with a > method "sort" that works by calling methods such as "greater" and > "equal" implemented in concrete subclasses. In FP, one would write a > function "sort" that takes as arguments a list of things to sort plus > a function to do the comparisons. At the top level of the program, > you'd see "interface comparable" in the OOP version and "function > sort" in the FP version. A mixed OOP-FP program might call the FP > function "sort" and pass the method "compare" of a subclass of > "comparable" as the comparison function.
Even the current Java libraries and object model belie this comparison. An array of intrisically comparable instances (those that "implement Comparable") can be sorted without supplying a Comparator. But an array of arbitrary Objects can be sorted in arbitrary and flexible ways by supplying a Comparable that accepts the types submitted to it. > Konrad. Randall Schulz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---