Hello, On Thu, Sep 24, 2009 at 5:09 PM, tmountain <tinymount...@gmail.com> wrote: > > To apply that to a data structure, you'd need to walk your structure > and compare the elements contained within against the desired type. > Depending on the structure, you could do something similar to this. > > (defn exclusively-contains-type? [datatype coll] > (every? true? (map #(instance? datatype %1) coll))) >
Thanks for the suggestions, walking the structure seems like the way to go. > This being said, Clojure is dynamically typed for a reason. It's best > not to enforce types with an iron fist unless you absolutely have to. > I've written large amounts of code without ever worrying about the > explicit concrete type working behind the scenes, but if it gives you > warm fuzzies, then by all means ;-). Well, I only want to enforce duck-typing :-) - for instance, make sure via unit tests that a function that should return a data structure with certain properties always returns such a data structure. I'll try to formalize my fuzzy ideas as code. Thanks for giving me some starting points. -- Miron Brezuleanu --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---