Re: Clojure, Slime and multiple file projects

2009-02-08 Thread mikel
On Feb 9, 1:05 am, Bradbev wrote: > Hi folks, > I'm getting to the stage on a Clojure project that I want to start > breaking the code into multiple files.  My primary environment is > Emacs & Slime and interactive development.  Is there a standard way > for me to load all of my project's files

Re: Clojure, Slime and multiple file projects

2009-02-08 Thread David Nolen
A simple solution is to define a namespace that brings in all of your different files. Is there some reason you can't do things this way? On Mon, Feb 9, 2009 at 8:05 AM, Bradbev wrote: > > Hi folks, > I'm getting to the stage on a Clojure project that I want to start > breaking the code into mul

Clojure, Slime and multiple file projects

2009-02-08 Thread Bradbev
Hi folks, I'm getting to the stage on a Clojure project that I want to start breaking the code into multiple files. My primary environment is Emacs & Slime and interactive development. Is there a standard way for me to load all of my project's files into the running VM? Right now I manually go t

Re: print/println vs. pr/prn

2009-02-08 Thread Chouser
On Sun, Feb 8, 2009 at 10:16 AM, Mark Volkmann wrote: > > I know print and println are intended for human readable output, > whereas pr and prn produce output that can be read by the Clojure > reader. I'm trying to find some cases where these differ. So far I've > only found String where print/pr

Re: Getting a result from a swing JDialog

2009-02-08 Thread Jeffrey Straszheim
A JDialog is going to run on the GUI thread and you can't change that. There are various concurrency tools in Java that will give you what you want. The easiest is to wait create a SynchronousQueue. Check the Java API docs. On Sat, Feb 7, 2009 at 6:15 PM, Tim Martin wrote: > > Hi all, > > I w

Re: Stack overflow problem

2009-02-08 Thread Jeffrey Straszheim
In fact, try this: (defn add-children [searchtype statelist] (let [c (children (first statelist)) s (rest statelist)] (cond (= searchtype :breadth-first) (doall (concat s c)) (= searchtype :depth-first) (doall (concat c s) The doall forces the lists the

Re: Stack overflow problem

2009-02-08 Thread Jeffrey Straszheim
Perhaps you are forcing a very long lazy list? Try (.printStackTrace *e) On Sun, Feb 8, 2009 at 9:41 AM, jodocus wrote: > > When I learn a new language, one of the programs I like to write as an > excercise is the n-queens problem (http://en.wikipedia.org/wiki/ > 8_queens

Re: Datalog update

2009-02-08 Thread Jeffrey Straszheim
By the way, if anyone on this list has experience implementing bottom-up optimizations for logic programs, particularly from the magic set family, and is willing to assist, please contact me. On Sun, Feb 8, 2009 at 7:47 PM, Jeffrey Straszheim < straszheimjeff...@gmail.com> wrote: > > Stratified n

Re: Datalog update

2009-02-08 Thread Jeffrey Straszheim
Stratified negation is working and in trunk. I have some cool ideas of a simple, but powerful, way to implement evaluable predicates. They'll likely make it in by midweek. The the hard part (magic sets) begins. On Feb 8, 11:43 am, Jeffrey Straszheim wrote: > I now have recursive queries worki

Re: Discarding entire transactions

2009-02-08 Thread Dan
On Sun, Feb 8, 2009 at 12:23 PM, Anand Patil < anand.prabhakar.pa...@gmail.com> wrote: > > Hello again, > > In my application, I'll frequently want to quickly discard all the > changes made during a transaction involving many refs. I don't want to > force the refs to roll back to their values at t

A pipe macro for left-to-right coll streams

2009-02-08 Thread MattH
Hi, I want to suggest a "pipe" macro for dealing with collection streams, as a one-line variation on the built in "->" macro. Instead of writing a nested stream like this: ; "Take the first 3 elements of the odd numbers in the range 1 to 20" (take 3 (filter odd? (range 1 20))) you can write

Re: Discarding entire transactions

2009-02-08 Thread Dan
> > (def a (ref 1)) > (def b (ref 1)) > > ; Do these concurrently, either from separate agents or using pmap > (dosync (commute b error-throwing-fn a)) > (dosync (commute a + @b)) > > I want to have the option to abort the first transaction without > rolling back the second. Based on what you said,

Getting a result from a swing JDialog

2009-02-08 Thread Tim Martin
Hi all, I was wanting to create a dialog box in a (predominantly command-line) application where the action of the user on the dialog box is returned to the code that requested the dialog so we can branch based on the selection. It seems the most natural way of doing this in a functional language

Stack overflow problem

2009-02-08 Thread jodocus
When I learn a new language, one of the programs I like to write as an excercise is the n-queens problem (http://en.wikipedia.org/wiki/ 8_queens). I wrote the program below which runs correctly. Using depth- first search, I have used it to find the solutions for board sizes up to 11 (after which i

clojure.inspector doesn't work on sets?

2009-02-08 Thread Tim Martin
Hi all, I was using clojure.inspector in my code, and to my surprise it failed when I applied it to a structure containing sets. The error message was that nth is not supported on the type PersistentHashSet. I've included a trivial patch below that seems to fix the problem. I'm not sure I unders

Re: Am I "holding on to the head" here ?

2009-02-08 Thread Jeffrey Straszheim
You're probably correct, but I'm still interested in the question in the more general sense. On Sun, Feb 8, 2009 at 5:17 PM, Kevin Downey wrote: > > I am not sure exactly how preduce differs from normal reduce, but > reduce is not a lazy operation, so it will result in the realization > of a laz

contrib sql - with-query-results macro

2009-02-08 Thread Mark Volkmann
The second argument to the with-query-results macro needs to be a vector containing a query string and optional values to be inserted into the query if it is parameterized. Would it be difficult to change this so in the case that the query is not parameterized, a string can be passed for the secon

Re: Am I "holding on to the head" here ?

2009-02-08 Thread Kevin Downey
I am not sure exactly how preduce differs from normal reduce, but reduce is not a lazy operation, so it will result in the realization of a lazy seq passed to it. On Sun, Feb 8, 2009 at 2:13 PM, Jeffrey Straszheim wrote: > I have this piece of code: > > (defn- run-work-elements-in-parallel > "

Am I "holding on to the head" here ?

2009-02-08 Thread Jeffrey Straszheim
I have this piece of code: (defn- run-work-elements-in-parallel "Runs a group of work elements in parallel. Returns an extended database." [elements database] (assert (set elements)) (let [[rec simp] (separate :recursive elements) results-simp (pmap #(run-simple-work-element % data

Re: clojure.contrib.sql connections

2009-02-08 Thread Jeffrey Straszheim
Great! On Sun, Feb 8, 2009 at 5:05 PM, Mark Volkmann wrote: > > On Sun, Feb 8, 2009 at 3:23 PM, Stephen C. Gilardi > wrote: > > > > On Feb 8, 2009, at 4:04 PM, Mark Volkmann wrote: > > > > The error I get is "org.postgresql.util.PSQLException: FATAL: no > > PostgreSQL user name specified in star

Re: clojure.contrib.sql connections

2009-02-08 Thread Mark Volkmann
On Sun, Feb 8, 2009 at 3:23 PM, Stephen C. Gilardi wrote: > > On Feb 8, 2009, at 4:04 PM, Mark Volkmann wrote: > > The error I get is "org.postgresql.util.PSQLException: FATAL: no > PostgreSQL user name specified in startup packet". I think the problem > is that the username and password values i

Re: clojure.contrib.sql connections

2009-02-08 Thread Jeffrey Straszheim
Please let us know if this works. On Sun, Feb 8, 2009 at 4:23 PM, Stephen C. Gilardi wrote: > > On Feb 8, 2009, at 4:04 PM, Mark Volkmann wrote: > > The error I get is "org.postgresql.util.PSQLException: FATAL: no > PostgreSQL user name specified in startup packet". I think the problem > is that

Re: clojure.contrib.sql connections

2009-02-08 Thread Stephen C. Gilardi
On Feb 8, 2009, at 4:04 PM, Mark Volkmann wrote: The error I get is "org.postgresql.util.PSQLException: FATAL: no PostgreSQL user name specified in startup packet". I think the problem is that the username and password values in db aren't used by with-connection unless a DataSource object is sp

Re: clojure.contrib.sql connections

2009-02-08 Thread Jeffrey Straszheim
Try :user instead of :username On Sun, Feb 8, 2009 at 4:04 PM, Mark Volkmann wrote: > > I'm trying to use the sql contrib library to connect to a Postgres > database. It's not clear to me how to specify a username and password. > Here's what I'm trying. > > (use 'clojure.contrib.sql) > > (let [db

ClassFormatError on compile

2009-02-08 Thread Chas Emerick
I am intermittently getting the following error when I attempt to perform an incremental compilation of a set of Clojure source files. To be clear, I mean "incremental" where I've previously compiled the sources down to classfiles, then changed one or more source files, and then run cloju

clojure.contrib.sql connections

2009-02-08 Thread Mark Volkmann
I'm trying to use the sql contrib library to connect to a Postgres database. It's not clear to me how to specify a username and password. Here's what I'm trying. (use 'clojure.contrib.sql) (let [db-host "localhost" db-name "ct" db-port 5432 subname (str "//" db-host ":" db-port

Re: Discarding entire transactions

2009-02-08 Thread Anand Patil
On Feb 8, 7:29 pm, Shawn Hoover wrote: > On Sun, Feb 8, 2009 at 12:23 PM, Anand Patil < > > anand.prabhakar.pa...@gmail.com> wrote: > > > Hello again, > > > In my application, I'll frequently want to quickly discard all the > > changes made during a transaction involving many refs. I don't want t

Re: Discarding entire transactions

2009-02-08 Thread Shawn Hoover
On Sun, Feb 8, 2009 at 12:23 PM, Anand Patil < anand.prabhakar.pa...@gmail.com> wrote: > > Hello again, > > In my application, I'll frequently want to quickly discard all the > changes made during a transaction involving many refs. I don't want to > force the refs to roll back to their values at t

Re: Discarding entire transactions

2009-02-08 Thread Jeffrey Straszheim
I don't think you can. There is no "rollback" function available. On Sun, Feb 8, 2009 at 12:23 PM, Anand Patil < anand.prabhakar.pa...@gmail.com> wrote: > > Hello again, > > In my application, I'll frequently want to quickly discard all the > changes made during a transaction involving many refs

Re: Newbie: applying arguments into a macro

2009-02-08 Thread samppi
Oh, yeah. Silly me, I *can* do that. Thanks a lot. It works like a charm now. On Feb 8, 2:17 am, Meikel Brandmeyer wrote: > Hi, > > Am 08.02.2009 um 00:40 schrieb samppi: > > > > > (defn conc* [tokens & subrules] > >  (loop [subrule-queue (seq subrules), remaining-tokens (seq tokens), > > produ

Re: IntelliJ Plugin -- Wonderful News!

2009-02-08 Thread Peter Wolf
I am using IDEA 9164. Make sure idea.jar is on your classpath (it is not part of the Development SDK). BTW to original plugin is still available pre-built. It works fine on Linux and Windows. See http://code.google.com/p/clojure-intellij-plugin/ Howard Lewis Ship wrote: > I'm trying to

Re: Questions about a Clojure Datalog

2009-02-08 Thread John Fries
reposted to correct a mistake in my use of X, Y and Z: --- I agree with Jeffrey that there is no reason to have just one option. Sometimes you want your reasoner to find a single model; sometimes you want it to find all models (assuming you are reasoning over a finite set). I've appen

Discarding entire transactions

2009-02-08 Thread Anand Patil
Hello again, In my application, I'll frequently want to quickly discard all the changes made during a transaction involving many refs. I don't want to force the refs to roll back to their values at the beginning of the transaction, I just want to end the transaction immediately and skip the write

Pmapping force over treed delays

2009-02-08 Thread Anand Patil
Hi all, Say I have a collection of delays, some of which need to get others' values in order to compute (there are no cyclic dependencies). If I just pmap force over the entire collection, do I run the risk of filling up a thread pool with operations that aren't ready to go yet? Would it be bette

Datalog update

2009-02-08 Thread Jeffrey Straszheim
I now have recursive queries working. My next 3 milestones are stratified negation, evaluable predicates, and then some version of magic sets optimization. But now, as long as your queries are non-negated it is working. http://code.google.com/p/clojure-datalog/ --~--~-~--~~-

Re: ANN: clojure.contrib.error-kit

2009-02-08 Thread Chouser
On Sun, Feb 8, 2009 at 9:24 AM, Meikel Brandmeyer wrote: > Hi, > > Am 08.02.2009 um 14:31 schrieb Chouser: > >> (deferror *foo* [*bar*] "Foo Error" [arg1]) >> (deferror *foo* "Foo Error" [*bar*] [arg1]) ; oops > > A question w/o looking at the actual implementation > code or further thinking abou

print/println vs. pr/prn

2009-02-08 Thread Mark Volkmann
I know print and println are intended for human readable output, whereas pr and prn produce output that can be read by the Clojure reader. I'm trying to find some cases where these differ. So far I've only found String where print/println output the value without quotes and pr/prn include the quot

Re: if-let

2009-02-08 Thread Adrian Cuthbertson
Thanks Meikel. There's always something new to learn. I'm also fast learning that if something doesn't look quite elegant in one's code, then there's bound to be an elegant clojure way of doing it! On Sun, Feb 8, 2009 at 4:51 PM, Meikel Brandmeyer wrote: > Hi, > > Am 08.02.2009 um 15:47 schrieb

Re: if-let

2009-02-08 Thread Meikel Brandmeyer
Hi, Am 08.02.2009 um 15:47 schrieb Adrian Cuthbertson: Here's one, I'm setting basedir to either :basedir in a map in *locs (a thread-local var) or to "." if :basedir was not found in the map... (let [basedir (if-let [bdir (:basedir *locs)] bdir ".")] ...) i.e bdir assumes the value of the

Re: if-let

2009-02-08 Thread Adrian Cuthbertson
Here's one, I'm setting basedir to either :basedir in a map in *locs (a thread-local var) or to "." if :basedir was not found in the map... (let [basedir (if-let [bdir (:basedir *locs)] bdir ".")] ...) i.e bdir assumes the value of the test and if that is not false (or nil) returns it otherw

Re: if-let

2009-02-08 Thread Meikel Brandmeyer
Hi, Am 08.02.2009 um 15:25 schrieb Mark Volkmann: Can someone show me an example of a good use of if-let? One use: (defn some-function [& args] (if-let [fst (first args)] (do-something-with fst) (do-something-else))) Sincerely Meikel smime.p7s Description: S/MIME cryptographi

if-let

2009-02-08 Thread Mark Volkmann
Can someone show me an example of a good use of if-let? I find its doc string a little confusing. It says "If test is true, evaluates then with binding-form bound to the value of test, if not, yields else". However, it doesn't have a parameter named "test". I assume it means "If the binding evalu

Re: ANN: clojure.contrib.error-kit

2009-02-08 Thread Meikel Brandmeyer
Hi, Am 08.02.2009 um 14:31 schrieb Chouser: (deferror *foo* [*bar*] "Foo Error" [arg1]) (deferror *foo* "Foo Error" [*bar*] [arg1]) ; oops A question w/o looking at the actual implementation code or further thinking about possible issues: Is there a reason why not to place the docstring as i

Re: ANN: clojure.contrib.error-kit

2009-02-08 Thread Chouser
On Sun, Feb 8, 2009 at 5:18 AM, David Nolen wrote: > > Sweet! I'm glad it's working for you, and that you have figured out how to use it despite the almost complete lack of docs. :-P > That said I do have one minor annoyance and that is the need to leave an > empty bracket if you want to creat

Re: ANN: clojure.contrib.error-kit

2009-02-08 Thread David Nolen
So far this is fantastic! And I haven't even got around to playing with the restart mechanism :) I'm using it in Spinoza to provide contextual errors (malformed slot list, missing base class etc.). I notice the contrib libraries in general are very good at throwing exceptions so that consumers hav

Re: Newbie: applying arguments into a macro

2009-02-08 Thread Meikel Brandmeyer
Hi, Am 08.02.2009 um 00:40 schrieb samppi: (defn conc* [tokens & subrules] (loop [subrule-queue (seq subrules), remaining-tokens (seq tokens), products []] (if (nil? subrule-queue) [products remaining-tokens] (let [[subrule-products subrule-remainder :as subrule-result]

Re: unchecked methods for floats/doubles?

2009-02-08 Thread Korny Sietsma
Excellent - thanks for clarifying this! - Korny On Sun, Feb 8, 2009 at 12:27 AM, Rich Hickey wrote: > > > On Feb 7, 2009, at 3:43 AM, Korny Sietsma wrote: > >> >> Ah - I didn't realise that. I was trying to avoid the overhead, as I >> understood it, of both converting the parameters to Float/D