On Mon, Jan 3, 2011 at 1:40 PM, MS <5lvqbw...@sneakemail.com> wrote: > Hi, I'm new to clojure (though I've messed around in scheme a little) > and I'm trying to represent an electrical circuit with "pins" and > "nets" (ie in graph terminology vertices and edges). > > I'd like to represent the nets as {:name "net_name" :pins #{pin1 pin2 > pin3}} etc. > I'd like to represent each pin as {:name "pin_name" :net the_net :type > pin_type} > > I want to query the net for all its attached pins, and to query any > pin to see what net it's attached to. The problem here is that these > are mutually-referring things. The net refers to the pins and each > pin refers back to the net. > > How do I create these without mutation?
I'd recommend something like this: {"pin_name1" {:name "pin_name1" :net "net_name1" :type ...} "pin_name2" {:name "pin_name2" :net "net_name1" :type ...} "pin_name3" {:name "pin_name3" :net "net_name1" :type ...} {"net_name1" {:name "net_name1" :pins #{"pin_name1" "pin_name2" "pin_name3"}} Each one refers not directly to others, but simply to Strings. Which can be used to look the others up in the two master hash maps. -- 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