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 richhic...@gmail.com 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

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: 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

Re: ANN: clojure.contrib.error-kit

2009-02-08 Thread Chouser
On Sun, Feb 8, 2009 at 5:18 AM, David Nolen dnolen.li...@gmail.com 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-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 evaluates

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
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 m...@kotka.de wrote: Hi, Am 08.02.2009 um

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

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

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

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: 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 m...@kotka.de wrote: Hi, Am 08.02.2009 um 00:40 schrieb samppi: (defn conc* [tokens subrules]  (loop [subrule-queue (seq subrules), remaining-tokens (seq tokens),

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. I

Re: Discarding entire transactions

2009-02-08 Thread Anand Patil
On Feb 8, 7:29 pm, Shawn Hoover shawn.hoo...@gmail.com 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

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 /

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

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

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 squee...@mac.com 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

Re: clojure.contrib.sql connections

2009-02-08 Thread Mark Volkmann
On Sun, Feb 8, 2009 at 3:23 PM, Stephen C. Gilardi squee...@mac.com 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

Re: clojure.contrib.sql connections

2009-02-08 Thread Jeffrey Straszheim
Great! On Sun, Feb 8, 2009 at 5:05 PM, Mark Volkmann r.mark.volkm...@gmail.comwrote: On Sun, Feb 8, 2009 at 3:23 PM, Stephen C. Gilardi squee...@mac.com wrote: On Feb 8, 2009, at 4:04 PM, Mark Volkmann wrote: The error I get is org.postgresql.util.PSQLException: FATAL: no PostgreSQL

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 %

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 straszheimjeff...@gmail.com wrote: I have this piece of code: (defn-

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

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 redc...@gmail.com 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

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

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

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

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 this:

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, if the

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 the

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 straszheimjeff...@gmail.com wrote: I now

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 rjek...@gmail.com 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: 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

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 t...@asymptotic.co.uk

Re: print/println vs. pr/prn

2009-02-08 Thread Chouser
On Sun, Feb 8, 2009 at 10:16 AM, Mark Volkmann r.mark.volkm...@gmail.com 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

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

Re: Clojure, Slime and multiple file projects

2009-02-08 Thread mikel
On Feb 9, 1:05 am, Bradbev brad.beveri...@gmail.com 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