Re: structures contains each other

2010-07-04 Thread Moritz Ulrich
Yup, clojure.contrib.graph is really cool. I'm implementing some pathfinding-stuff with it right now. The generic model (like using a function for the edges) is simple to use and very powerful. On Sat, Jul 3, 2010 at 4:08 AM, Chas Emerick wrote: > Take a look at clojure.contrib.graph.  It's very

Re: structures contains each other

2010-07-04 Thread ataggart
Assuming no need for coordination, atoms are a fine substitute for refs, but the structure should be similar to Laurent's example (thus avoiding conflation of identity and state), namely the var (e.g., n0, n1) should be an atom of a map containing atoms. E.g., user=> (defn set-in! [node in] (dosyn

Re: structures contains each other

2010-07-03 Thread Greg
This probably isn't the right way to do it, but it works: user=> (def n0 {:in (atom ()) :out (atom '(#'n1))}) #'user/n0 user=> (def n1 {:in (atom '(#'n0)) :out (atom ())}) #'user/n1 user=> (swap! (:in n0) conj '#'n3) ((var n3)) user=> n0 {:in #, :out #} user=> @(eval (first @(:in n1))) {:in #, :o

Re: structures contains each other

2010-07-02 Thread Chas Emerick
Take a look at clojure.contrib.graph. It's very basic, but has a nice generic model. - Chas On Jul 2, 2010, at 3:15 PM, Mate Toth wrote: I'm building a directed graph library, where the nodes has "out" and "in" fields. If I connect a node, let's say: (node->node n0 n1) then the node's field

Re: structures contains each other

2010-07-02 Thread Laurent PETIT
I've also struggled with the same concepts in my head in the past. One answer to try explain why it is not possible, is that if you do that, you somehow try to conflate identity and state again. When you write n0: in () out (n1) and n1 in(n0) out() , it seems to me that when you write n0:in() out

structures contains each other

2010-07-02 Thread Mate Toth
I'm building a directed graph library, where the nodes has "out" and "in" fields. If I connect a node, let's say: (node->node n0 n1) then the node's fields would be the following: n0: in: () out: (n1) n1: in: (n0) out () My problem is that if I update n0 I could only add the old "instance" to t