user> (topological-sort {0 [1] 1 [2 3] 2 [3] 3 []})
(3 2 0 1)
!
--
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 - plea
brilliant, this has been very helpful - thanks to both for taking the
time to answer!
On Nov 12, 6:06 am, John Harrop jharrop...@gmail.com wrote:
On Wed, Nov 11, 2009 at 2:04 PM, Nick Day nicke...@gmail.com wrote:
Hi,
I've been trying to implement a topological sort and have been
Just for the fun of writing it:
(defn topological-sort [x]
(mapcat
#(for [[k v] % :when (empty? v)] k)
(take-while seq
(iterate #(into {} (for [[k v] % :when (seq v)] [k (mapcat % v)])) x
user= (topological-sort {1 [2 3] 2 [3] 3 []})
(3 2 1)
Note that it's not the same
Hi,
I've been trying to implement a topological sort and have been
struggling a bit. I have a map of symbol vs collection of symbols
like:
{a [b c], b [c], c [nil]}
which can be read as 'a' depends on 'b' and 'c', 'b' depends on 'c'
and 'c' doesn't depend on anything. I've been trying to write
Nick Day nicke...@gmail.com writes:
I've been trying to implement a topological sort and have been
struggling a bit. I have a map of symbol vs collection of symbols
like:
{a [b c], b [c], c [nil]}
which can be read as 'a' depends on 'b' and 'c', 'b' depends on 'c'
and 'c' doesn't depend
On Wed, Nov 11, 2009 at 2:04 PM, Nick Day nicke...@gmail.com wrote:
Hi,
I've been trying to implement a topological sort and have been
struggling a bit. I have a map of symbol vs collection of symbols
like:
{a [b c], b [c], c [nil]}
which can be read as 'a' depends on 'b' and 'c', 'b