could you not just use a map?
(def sources {:bbc "bbc.co.uk" :google "google.com" ...})
On Sat, Nov 5, 2011 at 6:14 AM, Mark Derricutt <[email protected]> wrote:
> Would something like:
> (def ^:dynamic *SOURCES* (ref []))
> (defrecord Source [name url])
> (defmacro defsource [name url]
> `(dosync (alter *SOURCES* conj (Source. ~name ~url))))
> (defn get-all-sources [] @*SOURCES*)
> (defsource "Google" "google.com")
> do ok?
> Man - it's been too long since I've done clojure - so rusty :)
>
>
> --
> "Great artists are extremely selfish and arrogant things" — Steven Wilson,
> Porcupine Tree
>
>
> On Sat, Nov 5, 2011 at 11:03 PM, Colin Taylor <[email protected]>
> wrote:
>>
>> Hi,
>>
>> given a namespace sources
>>
>> with [simplified definitions]
>>
>> (defrecord Source [name url])
>>
>> (def google (source "Google" "google.com"))
>> (def bbc (source "BBC" "bbc.co.uk"))
>> (def nbc ...
>> etc.
>>
>> what would be the idiomatic way to implement
>>
>> (defn get-all-sources)
>>
>> cheers
>> Colin
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to [email protected]
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> 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
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with your
> first post.
> 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
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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