i used a java priorityqueue for this. it's mutable (but local), and since
you're not going to access he queue with more than in thread you can hide
this fact and still pretend to be functional.
i did it. in reality, cheats are always allowed.
2012/11/21 Sergey Didenko
> I have used mutable code
I have used mutable code working on Java structures when I was
implementing the kind of Dijkstra algorithm. As long as it is
encapsulated in a function it seems quite a good approach to me.
And also quite readable given the amount of mutable Dijkstra examples
in the Internet.
--
You received thi
I'll look into this. Actually, I was thinking of implementing A* as well,
so thanks!
On Tuesday, 20 November 2012 13:18:08 UTC-5, puzzler wrote:
>
> I just responded in your other thread, suggesting you look at
> priority-map. Now that I see this thread, I can tell you that priority-map
> is
Perhaps because you are still using a bad comparison function when constructing
the sorted-set?
(see reply on other thread)
That said, Mark's suggestion of a using a priority queue is also a good one.
Andy
On Nov 20, 2012, at 9:57 AM, JvJ wrote:
> I actually did try that, but somehow disj was
I just responded in your other thread, suggesting you look at
priority-map. Now that I see this thread, I can tell you that priority-map
is definitely what you want rather than sorted sets -- I created it
specifically for that kind of algorithm.
Check out: http://clj-me.cgrand.net/2010/09/04/a-in
I actually did try that, but somehow disj wasn't working properly.
user> (def test-set (sorted-set-by msinterview/d-comp [:A [[:A] 0]] [:B
[[:A :B] 10]]))
#'user/test-set
user> test-set
#{[:A [[:A] 0]] [:B [[:A :B] 10]]}
user> (disj test-set (first test-set))
#{[:A [[:A] 0]] [:B [[:A :B] 10]]}
O
Have you tried using first to get the smallest item from the set, and then
create a new sorted set with the item remove by using (disj my-sorted-set item)
?
Andy
On Nov 20, 2012, at 9:46 AM, JvJ wrote:
> I've just implemented Dijkstra's algorithm, and as far as I can tell, it
> works.
>
> Ho
I've just implemented Dijkstra's algorithm, and as far as I can tell, it
works.
However, I'm a little concerned at the efficiency. Specifically, I am
using sorted sets, and I can't break apart the set into first/next and keep
it as a set. I have to get next as a sequence and then apply sorted