Hi,

On 4 Nov., 15:03, Konrad Hinsen <[EMAIL PROTECTED]> 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.

And as an effect of not forcing the sorting logic into some class,
one can easily sort the same data in different ways in the FP style.
While implementing an interface Comparable defines *one* way
of sorting, the FP style separates the functions from the data. So
it is eg. easily possible to sort a list of email objects by subject,
author or date, or any combination thereof.

Sincerely
Meikel
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to