Re: finding paths in clojure with Floyd-Warshall - ugly code

2009-09-15 Thread Christophe Grand
Hello, On Mon, Sep 14, 2009 at 11:48 PM, ajuc aju...@gmail.com wrote: Hello, I'm new in clojure and lisp, and I have problem with making this code elegant (or at least short). This is Floyd-Warshall algorithm - very simple algorithm in imperative form (3 nested for loops). In clojure the

Re: questions about datalog

2009-09-15 Thread Mark Engelberg
On Mon, Sep 14, 2009 at 10:02 PM, Tom Faulhaber tomfaulha...@gmail.com wrote: Did you also read the overview that's part of contrib at http://richhickey.github.com/clojure-contrib/doc/datalog.html. So because of this thread, I just went and perused the description of the Clojure datalog

Re: Modeling Data Associations in Clojure?

2009-09-15 Thread Dragan Djuric
Ha, ha, some object-oriented lessons are being rediscovered :))) For example, you would have an opaque Person object, perhaps in a Ref, and functions like get-name, set-name, get-policy, etc.  The underlying storage model can be whatever you want -- sets, SQL, files,  You just have to

Mutating state in java super classes

2009-09-15 Thread Rick Moynihan
Hi all, I'm looking at extending a java class in clojure, however I can't find any mention of how to access or change state within my super class object e.g. given a java class like this: public class Foo { protected int foo = 10; // ... } How can I write the equivalent of this in

Re: finding paths in clojure with Floyd-Warshall - ugly code

2009-09-15 Thread ajuc
[snip] You are accumulating a result, which hints us at 'reduce. And 'for provides the nested enumeration: (defn floyd-warshall2 [{:keys [nodes distances]}]   (reduce (fn [[distances prevs] [k x y]]             (let [d (+ (distances [x k] Double/POSITIVE_INFINITY)                      

Re: finding paths in clojure with Floyd-Warshall - ugly code

2009-09-15 Thread Timothy Pratley
I thought it would be interesting to make a version which spits out the paths: http://github.com/timothypratley/strive/blob/master/clj/sandpit/fw.clj shortest-path 7 2: ({:node 7, :step-cost 0, :remaining-cost 6} {:node 8, :step-cost 1, :remaining-cost 5} {:node 6, :step-cost 1,

Re: Mutating state in java super classes

2009-09-15 Thread Chouser
On Tue, Sep 15, 2009 at 7:15 AM, Rick Moynihan rick.moyni...@gmail.com wrote: Hi all, I'm looking at extending a java class in clojure, however I can't find any mention of how to access or change state within my super class object e.g. given a java class like this: public class Foo {  

Re: Conjure 0.2 released.

2009-09-15 Thread Matt
That's my plan for the next release. Unfortunately, the change to test- is came out right before I finished the release. After reviewing what it would take to update, I decided to wait. If you make the changes on your fork, I'll be happy to merge them in. -Matt On Sep 14, 11:31 am, Stuart

Re: Conjure 0.2 released.

2009-09-15 Thread Matt
Fixed in the main branch. Stu made the change on his fork, and I merged it in. -Matt On Sep 14, 2:52 pm, Jim Menard jim.men...@gmail.com wrote: Matt, There's a missing double quote on line 11 of lancet.sh. After adding that, I had no problem compiling Conjure. Looking forward to trying it.

Re: Conjure 0.2 released.

2009-09-15 Thread Stuart Halloway
The bigger problem here is that the ant jar task loses file permissions, so after Conjure expands the file structure to create a project Unix users will have to chmod u+x any files that are scripts. I looked at it for about 10 seconds and decided it wasn't easily fixable without going

Unwind-protect?

2009-09-15 Thread Gorsal
I was just wondering about the unwind-protect form, I've heard that it doesn't protect against certain types of exits, but what exactly are these exits? I've heard return, break, and continue statements said but i can't seem to find these statements in clojure. Any examples?

Re: Unwind-protect?

2009-09-15 Thread Jarkko Oranen
On Sep 15, 6:54 pm, Gorsal s...@tewebs.com wrote: I was just wondering about the unwind-protect form, I've heard that it doesn't protect against certain types of exits, but what exactly are these exits? I've heard return, break, and continue statements said but i can't seem to find these

Re: A problem with compilation Clojure files

2009-09-15 Thread TPJ
On 14 Wrz, 19:51, Michael Wood esiot...@gmail.com wrote: (...) What does your runclojure script look like? Yes, that's the point. If the problem isn't in the Clojure itself, nor in the source file, and the files are placed exactly where they should be, the only possibility is the script used

Re: A problem with compilation Clojure files

2009-09-15 Thread TPJ
On 14 Wrz, 20:06, Richard Newman holyg...@gmail.com wrote: Nope, it's not that easy. I changed clojure.example.hello to clojure.examples.hello in the hello.clj file, and the message was still the same. (Hard to believe, isn't it?) What's the value of *compile-path*? Is it in your

Re: A problem with compilation Clojure files

2009-09-15 Thread Richard Newman
Although I still don't understand why the current working directory can cause such problems (shouldn't Java be able to make proper use of the classpath?), my problem has been solved. Because the compilation of Clojure files produces files in *compile- path* (classes by default), which is

Accessing a protected final method of the superclass

2009-09-15 Thread Sir Diddymus
Dear all, I've successfully extended a Java class (:gen-class and :extends) and all is working as expected, until I was forced to call a protected final method of the superclass from within my derived class. I don't seem find a way to do this (:exposes-methods really is only for overridden

Re: Accessing a protected final method of the superclass

2009-09-15 Thread Chouser
On Tue, Sep 15, 2009 at 2:08 PM, Sir Diddymus sirdidd...@googlemail.com wrote: Dear all, I've successfully extended a Java class (:gen-class and :extends) and all is working as expected, until I was forced to call a protected final method of the superclass from within my derived class. I

What happened to the set operations?

2009-09-15 Thread Brian Hurt
The API documentation: http://clojure.org/data_structures#toc22 mentions the existence of the basic set operations of union, intersection, and difference. But these functions don't seem to exist anymore (including in the version of clojure I pulled from github about five minutes ago). I was

Re: What happened to the set operations?

2009-09-15 Thread Richard Newman
The API documentation: http://clojure.org/data_structures#toc22 mentions the existence of the basic set operations of union, intersection, and difference. But these functions don't seem to exist anymore (including in the version of clojure I pulled from github about five minutes

Re: Unwind-protect?

2009-09-15 Thread Gorsal
Ah, I thought there was a contrib out there for unwind-protect . I guess its so trivial that no one wrote it. lol. On Sep 15, 12:25 pm, Joost jo...@zeekat.nl wrote: On 15 sep, 18:19, Jarkko Oranen chous...@gmail.com wrote: Unwind-protect? Isn't that a Common Lisp thing? Sounds like you got

Re: What happened to the set operations?

2009-09-15 Thread B Smith-Mannschott
On Tue, Sep 15, 2009 at 21:47, Brian Hurt bhur...@gmail.com wrote: The API documentation: http://clojure.org/data_structures#toc22 mentions the existence of the basic set operations of union, intersection, and difference.  But these functions don't seem to exist anymore (including in the

Re: Conjure 0.2 released.

2009-09-15 Thread Matt
I'll make a note on the wiki to chmod the scripts in Unix. I'm not sure what else I can do. I swear I tested all of this on my Mac. -Matt On Sep 15, 10:17 am, Stuart Halloway stuart.hallo...@gmail.com wrote: The bigger problem here is that the ant jar task loses file   permissions, so after

Ensure and STM: find the bug...

2009-09-15 Thread Krukow
After a discussion in dcug about the write-skew anomaly, I wanted to write a program exhibiting the anomaly, together with a similar program using ensure to eliminate it. My program doesn't work: it exhibits the anomaly, but ensure doesn't fix it, and neither does adding a validator to the refs.

Re: Clojure for game programming?

2009-09-15 Thread Elliott Slaughter
On Sep 15, 9:27 am, CuppoJava patrickli_2...@hotmail.com wrote: Yes. I haven't personally run into any problems (since I handle my own threading), but it's explicitly stated that you shouldn't put mutable data into Clojure's immutable data structures. It's possible that I misunderstood what

Re: Ensure and STM: find the bug...

2009-09-15 Thread Mark Volkmann
I think the problem is that you only ensure one of the Refs. If you want to make sure that a condition between multiple Refs isn't violated, you need to sure all of them. Otherwise other transactions will be free to modify the Refs that aren't ensured. On Tue, Sep 15, 2009 at 3:14 PM, Krukow

Re: Ensure and STM: find the bug...

2009-09-15 Thread Mark Volkmann
On Tue, Sep 15, 2009 at 3:23 PM, Mark Volkmann r.mark.volkm...@gmail.com wrote: I think the problem is that you only ensure one of the Refs. If you want to make sure that a condition between multiple Refs isn't violated, you need to sure I meant ensure instead of sure. all of them.

clojure shell window?

2009-09-15 Thread ddyer
I've been looking for a Clojure REPL loop in a java window, the general idea is to use it as an ad-hoc inspector for existing java programs. Does this already exist? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Method combination (as in CL)?

2009-09-15 Thread Elliott Slaughter
Hi, I'm visiting from the Common Lisp world and I'm wondering if Clojure's multimethods support method combination? (Please forgive me if this has already been asked and just direct me to the relevant documentation.) Here's a contrived example. B derives from A and both have methods defined for

Re: clojure shell window?

2009-09-15 Thread kyle smith
repl.clj in the files section of the group is exactly what you want. --~--~-~--~~~---~--~~ 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

Re: Method combination (as in CL)?

2009-09-15 Thread Richard Newman
I'm visiting from the Common Lisp world and I'm wondering if Clojure's multimethods support method combination? (Please forgive me if this has already been asked and just direct me to the relevant documentation.) Discussed previously:

Re: Unwind-protect?

2009-09-15 Thread Michael Wood
2009/9/15 Gorsal s...@tewebs.com: Ah, I thought there was a contrib out there for unwind-protect . I guess its so trivial that no one wrote it. lol. There's error-kit: http://richhickey.github.com/clojure-contrib/error-kit-api.html Not sure how much that is or is not like unwind-protect. --

Re: Ensure and STM: find the bug...

2009-09-15 Thread Timothy Pratley
I ran program #1 and #2 on Clojure 1.1.0-alpha-SNAPSHOT from git - program #1 output skew - program #2 no output What version are you using? Could be something that's been fixed recently. On Sep 16, 6:14 am, Krukow karl.kru...@gmail.com wrote: After a discussion in dcug about the write-skew

Re: Unwind-protect?

2009-09-15 Thread Stuart Sierra
unwind-protect is indeed a Common Lisp form, not Clojure. It ensures that a given piece of code is always executed, even when an error or some other condition causes the code to exit early. In Clojure (and Java), the nearest equivalent is the try-catch-finally block. It looks like this: (try

Re: Modeling Data Associations in Clojure?

2009-09-15 Thread Stuart Sierra
On Sep 15, 6:54 am, Dragan Djuric draga...@gmail.com wrote: Ha, ha, some object-oriented lessons are being rediscovered :))) Precisely! Just because the language doesn't enforce information hiding doesn't mean you can't do it. -SS --~--~-~--~~~---~--~~ You

Re: Modeling Data Associations in Clojure?

2009-09-15 Thread Brenton
Thank you all for your input. I think I will follow Stuart's advice and go with something like the following, again using the example data above. (use 'clojure.set) (def policies (ref #{{:id 3 :name x :holder 7 :vehicle 11} {:id 4 :name y :holder 2 :vehicle 12}}))

Re: Ensure and STM: find the bug...

2009-09-15 Thread Krukow
On Sep 15, 10:23 pm, Mark Volkmann r.mark.volkm...@gmail.com wrote: I think the problem is that you only ensure one of the Refs. If you want to make sure that a condition between multiple Refs isn't violated, you need to sure all of them. Otherwise other transactions will be free to modify

Re: Ensure and STM: find the bug...

2009-09-15 Thread Krukow
On Sep 16, 12:32 am, Timothy Pratley timothyprat...@gmail.com wrote: I ran program #1 and #2 on Clojure 1.1.0-alpha-SNAPSHOT from git - program #1 output skew - program #2 no output What version are you using? Could be something that's been fixed recently. I was running a fairly recent,

Re: Ensure and STM: find the bug...

2009-09-15 Thread Christophe Grand
On Wed, Sep 16, 2009 at 6:13 AM, Krukow karl.kru...@gmail.com wrote: On Sep 15, 10:23 pm, Mark Volkmann r.mark.volkm...@gmail.com wrote: I think the problem is that you only ensure one of the Refs. If you want to make sure that a condition between multiple Refs isn't violated, you need to