This works fine as well. More to digest. Thanks.
On 19 Aug, 20:06, Benny Tsai wrote:
> This is one way to do it functionally, though it's a bit more verbose.
>
> "get-nodes" performs a BFS walk of the tree between two nodes, returning the
> set of visited nodes:
>
> (defn get-nodes [from to]
>
It works great. Thanks a lot. I had a feeling concat and reduce were
needed; I just couldn't figure out how.
On 19 Aug, 22:10, Justin Kramer wrote:
> Oops, renamed the function: get-edges = candidates->edges.
>
> Justin
>
>
>
>
>
>
>
> On Friday, August 19, 2011 4:03:27 PM UTC-4, Ulrik Sandberg w
Oops, renamed the function: get-edges = candidates->edges.
Justin
On Friday, August 19, 2011 4:03:27 PM UTC-4, Ulrik Sandberg wrote:
>
> And get-edges?
>
> On 19 Aug, 20:52, Justin Kramer wrote:
> > Here's another way, which constructs a sequence of edges using
> candidates,
> > which are th
And get-edges?
On 19 Aug, 20:52, Justin Kramer wrote:
> Here's another way, which constructs a sequence of edges using candidates,
> which are then fed into reduce to build an adjacency list.
>
> (defn candidates->edges [candidates from to]
> (when-let [kids (seq (candidates from to))]
> (c
2011/8/19 J. Pablo Fernández :
> Petr, I do not care about this particular error, but about how to deal with
> this one liners. Ambrose's reply is what I needed, and no, it's not
> PostgreSQL problem. It's a library trying to establish a connection when it
> shouldn't with credentials that should n
Here's another way, which constructs a sequence of edges using candidates,
which are then fed into reduce to build an adjacency list.
(defn candidates->edges [candidates from to]
(when-let [kids (seq (candidates from to))]
(concat (for [k kids] [from k])
(mapcat #(get-edges cand
Probably a good idea for "get-nodes" to handle potential cycles:
(defn get-nodes [from to]
(loop [visited #{}
[x & xs] [from]]
(if-not x
visited
(let [new-visited (conj visited x)
neighbors (candidates x to)
new-queue (remove new-visited (concat x
This is one way to do it functionally, though it's a bit more verbose.
"get-nodes" performs a BFS walk of the tree between two nodes, returning the
set of visited nodes:
(defn get-nodes [from to]
(loop [queue [from]
visited #{}]
(let [[x & xs] queue]
(if-not x
visite
Sorry for being unclear.
I would in fact like to _create_ an adjacency list, given a start and
end key, and the candidates function I mentioned. However, I have
problems with coming up with a functional algorithm. I have a stateful
one that works, but it's very ugly.
(defn build-tree [from to m]
Hi all,
As part of my attempt to learn Clojure, I've cooked up a simple
Prisoner's Dilemma simulation. I'd love any feedback the group would
care to provide about my implementation, as I'm eager to improve. I've
got thick skin so fire away!
Annotated source:
http://xmlblog.github.com/prisoners/
I'm not sure if I'm addressing your needs exactly, but if you want to turn
an adjacency list into a nested structure, here's one way:
(def adj {:a [:b] :b [:c :d] :c [:e] :d [:e]})
(defn build-tree [adj from to]
{:name from
:children (when (not= from to)
(map #(build-tree adj
Petr, I do not care about this particular error, but about how to deal with
this one liners. Ambrose's reply is what I needed, and no, it's not
PostgreSQL problem. It's a library trying to establish a connection when it
shouldn't with credentials that should never be used because I never
specif
On Thu, Aug 18, 2011 at 1:39 AM, Jim Blomo wrote:
> Hi, I'm enjoying playing with ClojureScript so far, great job guys!
> I'm wondering if functions like ns-aliases and Vars like *ns* will be
> implemented in future versions of ClojureScript. If not, are there
> recommended workarounds or should
This is postgresql exception so problem is there (it's not Clojure's
one). Just try to connect via some other tool to confirm this, use
psql in command line, for example. Maybe there is missing group role
that is linked to login role 'mgr'.
PS: I hope that password is not a confidential one :)
20
This is a bug in `rename`.
That needs to be worked on, thanks for pointing it out.
In the meantime, please use
(-> (table nil :users)
(project [[:id :as :idx]
:name])
to-sql)
in the meantime.
regards
2011/8/17 David Jagoe
> Hi All,
>
> Could someone wit
Thanks. That looks very interesting.
> ;; adjacency list
> {:a [:b] :b [:c :d] :c [:e] :d [:e]}
For some reason, I have trouble constructing this recursively. I seem
to always end up with something like this:
user> (build-tree :a :e)
(:a (:b (:c (:e)) (:d
(:e
(defn build-tree [from to]
(c
There are many ways one could model a tree/graph:
;; collection of edges
[[:a :b] [:b :c] [:b :d] [:c :e] [:d :e]]
;; adjacency list
{:a [:b] :b [:c :d] :c [:e] :d [:e]}
If you're looking for a pre-made solution, the loom graph library
(https://github.com/jkk/loom) may work:
(ns example
(:us
I would be concerned about this group, if there was any evidence of
existence.
On Aug 19, 2:59 am, Ken Wesson wrote:
> And, maybe, the ones who have to go and reconfigure everything when
> they upgrade ...
>
--
You received this message because you are subscribed to the Google
Groups "Clojure"
On Fri, Aug 19, 2011 at 3:57 AM, Ken Wesson wrote:
> On Thu, Aug 18, 2011 at 11:00 PM, Meikel Brandmeyer wrote:
> > Eh, what exactly does slideshare provide over a PDF put on some server
> somewhere?
>
> Apparently, the ability to annoy the hell out of whoever you try to
> share it with.
You c
I have data that I would like to represent as a non-binary tree, or perhaps
a graph, but I'm not sure how to do that. The sample data looks like this:
A->B
B->C,D
C->E
D->E
Here the number of subnodes from B are just two, but they may be any number,
which is the source of my confusion. Binary tre
Awesome talk - thanks!
I particularly enjoyed the sign behind you that says "Don't Panic!" - it helped
keep me calm during the hairily complex parts :-)
I really look forward to seeing where you go with this stuff…
Sam
---
http://sam.aaron.name
On 18 Aug 2011, at 21:10, David Nolen wrote:
>
Hi,
The last thrown Exception/Error is kept in the var *e.
You should be able to view the complete stack trace of the last thrown
exception by calling something like:
(.printStackTrace *e)
Ambrose
2011/8/19 J. Pablo Fernández
> Hello Clojurians,
>
> I'm struggling to work with errors in Cloj
On Thu, Aug 18, 2011 at 11:05 PM, dmiller wrote:
> Several comments:
>
> (a) 'clojure.load.path' is not new in 1.3. It's been in the code
> since at least May, 2009.
> (b) Regarding Dimitre's comment below, I probably did have Java system
> properties on my mind at the time. I guarantee that I w
Hello Clojurians,
I'm struggling to work with errors in Clojure. This is one example, one
case, but I had many like these before:
user=> (load-file "/Users/pupeno/Projects/mgr/src/lobos/migrations.clj")
org.postgresql.util.PSQLException: FATAL: role "lobos" does not exist
(config.clj:1)
It jus
On Thu, Aug 18, 2011 at 11:00 PM, Meikel Brandmeyer wrote:
> Eh, what exactly does slideshare provide over a PDF put on some server
> somewhere?
Apparently, the ability to annoy the hell out of whoever you try to
share it with.
--
Protege: What is this seething mass of parentheses?!
Master: Yo
25 matches
Mail list logo