On 15 February 2011 22:53, MS <5lvqbw...@sneakemail.com> wrote: >> So an electrical circuit is a data structure containing vertices and >> edges and describing how they are connected. Then you'll have some >> functions that operate on that data structure. > > So... how do I use someone else's implementation of some type of graph > algorithm as applied to my circuit structure, unless I use their > structure?
The short answer is protocols: http://clojure.org/protocols. However, calling a protocol method has the same syntax as calling a normal function. So you can start by writing functions specific to a certain graph implementation, and then painlessly convert convert them into a protocol when you actually need polymorphism. The actual code that uses these functions/methods need not change. To put it another way, OOP languages tend to emphasize thinking about polymorphism before you need it. In Clojure, you should generally only think about polymorphism when you actually need it. So if you don't have two equally-good graph data structures sitting in the wings, just write it using normal functions for now. - James -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en