Add-classpath

2009-07-10 Thread Tayssir John Gabbour
Hi! Does anyone know when add-classpath might start working again? http://groups.google.com/group/clojure/browse_frm/thread/ad254be133a9b47a/ab6585a430e21346? (It didn't even work for me when I downloaded the v1.0 release. I'm on MacOS 10.4, running under Emacs/Slime. I have recent Clojure insta

The snake again - Programming Clojure book

2009-07-10 Thread Rowdy Rednose
Why does the Snake example in the book use refs when all mutation is done from the EDT? To verify that, I put a call to "assert-edt" in front of every dosync in snake.clj. assert-edt is defined like this: (defn assert-edt [] (assert (javax.swing.SwingUtilities/ isEventDispatchThread))) And it n

Re: Best way to create nonref variable?

2009-07-10 Thread John Harrop
On Thu, Jul 9, 2009 at 10:29 PM, J. McConnell wrote: > You can try with-local-vars. I'm not sure of the performance > characteristics of this versus using an atom, but it certainly feels > more imperative: It's slow. I suspect it (and binding) uses Java's ThreadLocal, which is slow. Loop/recur

*math-context*

2009-07-10 Thread John Harrop
It would be useful to have a *math-context* or similar that had a sensible default and could be set with binding to affect bigdec calculations within the temporal scope of said binding. --~--~-~--~~~---~--~~ You received this message because you are subscribed to th

flatten tools

2009-07-10 Thread kyle smith
I wrote these and thought they might be useful. Feel free to add them to clojure.contrib.seq-utils (defn flatten-n [n coll] "Like flatten, but only goes n levels deep." (if (= n 0) coll (recur (dec n) (apply concat (map #(if (sequential? %) % (list %)) coll) (defn- unflatten* [t

Re: *math-context*

2009-07-10 Thread Chouser
On Fri, Jul 10, 2009 at 7:14 AM, John Harrop wrote: > It would be useful to have a *math-context* or similar that had a sensible > default and could be set with binding to affect bigdec calculations within > the temporal scope of said binding. user=> (binding [*math-context* (java.math.MathContex

clojure.contrib.sql - docallable method

2009-07-10 Thread markgunnels
Hello, I wanted to recommend the following method be added to clojure.contrib.sql (stolen directly from do-prepared). I have used it successfully with Oracle stored procedure calls. Please let me know if I'm not posting to the right place or in the right manner or any improvements that can be mad

Re: *math-context*

2009-07-10 Thread Rich Hickey
On Jul 10, 9:01 am, Chouser wrote: > On Fri, Jul 10, 2009 at 7:14 AM, John Harrop wrote: > > It would be useful to have a *math-context* or similar that had a sensible > > default and could be set with binding to affect bigdec calculations within > > the temporal scope of said binding. > > user

Re: From Java to Clojure

2009-07-10 Thread Benjamin Stewart
I've been playing along at home for awhile now, but this example hit close to home -- I've written variations on this code countless times in perl, and figured I'd take a stab at clojuring it while also taking advantage of clojure.contrib.seq-utils's very useful to the matter at hand group-by. I'

Re: The snake again - Programming Clojure book

2009-07-10 Thread Stuart Halloway
Hi Rowdy, The snake uses refs because idiomatic Clojure code should not require binding to a thread. The snake game could be extended to be a simulation that runs on multiple threads (or perhaps even multiple machines) without having to change the basic code. Normally, you wouldn't build

Re: The snake again - Programming Clojure book

2009-07-10 Thread Rowdy Rednose
On Jul 10, 10:28 pm, Stuart Halloway wrote: > binding to a thread. The snake game could be extended to be a   > simulation that runs on multiple threads (or perhaps even multiple   Makes sense. For the example in the book it just seemed completely redundant. And when writing Swing code, at least

Re: Bug with struct-maps and *print-dup*

2009-07-10 Thread J. McConnell
On Thu, Jul 9, 2009 at 11:31 PM, Mark Engelberg wrote: > > I'm running Clojure 1.0. > > Could someone please check and see whether this is still a bug in the > most current version? Yup, I still see the same behavior in HEAD. - J. --~--~-~--~~~---~--~~ You receiv

Re: The snake again - Programming Clojure book

2009-07-10 Thread Stuart Halloway
To rebind a macro in clojure.core you would need to first enter that namespace: (in-ns 'clojure.core) Or, create your own dosync in a different namespace which explicitly does not refer to clojure.core/dosync. See the docstring for clojure.core/ns for using :exclude. Stuart > > On Jul 10

Re: *math-context*

2009-07-10 Thread John Harrop
On Fri, Jul 10, 2009 at 9:22 AM, Rich Hickey wrote: > On Jul 10, 9:01 am, Chouser wrote: > > On Fri, Jul 10, 2009 at 7:14 AM, John Harrop > wrote: > > > It would be useful to have a *math-context* or similar that had a > sensible > > > default and could be set with binding to affect bigdec calcu

Re: *math-context*

2009-07-10 Thread Rich Hickey
On Jul 10, 9:44 am, John Harrop wrote: > On Fri, Jul 10, 2009 at 9:22 AM, Rich Hickey wrote: > > On Jul 10, 9:01 am, Chouser wrote: > > > On Fri, Jul 10, 2009 at 7:14 AM, John Harrop > > wrote: > > > > It would be useful to have a *math-context* or similar that had a > > sensible > > > > defa

Re: Problem with clojure code on .net.

2009-07-10 Thread mmwaikar
Hi, I am facing another problem now. Please take a look at this code - (import '(System.IO Path Directory File StreamWriter DirectoryNotFoundException)) (import '(System.Diagnostics Process ProcessStartInfo ProcessWindowStyle)) (defn strt [tool] (let [info (ProcessStartInfo. tool) p (Pr

Re: The snake again - Programming Clojure book

2009-07-10 Thread Rowdy Rednose
This did the trick: (ns clojure.core) (defmacro dosync [& body] `(do (assert (not (javax.swing.SwingUtilities/isEventDispatchThread))) (#'dosync ~...@body))) This is great for testing! Thanks for your help, Stu. And btw the book is really great so far (and I'm almost through)! It pr

Re: clojure.contrib.sql - docallable method

2009-07-10 Thread Stephen C. Gilardi
On Jul 10, 2009, at 9:22 AM, markgunnels wrote: I wanted to recommend the following method be added to clojure.contrib.sql (stolen directly from do-prepared). I have used it successfully with Oracle stored procedure calls. Please let me know if I'm not posting to the right place or in the right

Re: clojure.contrib.sql - docallable method

2009-07-10 Thread markgunnels
Hi Stephen, That name sounds much better than mine and sorry for breaking process. The code was definitely a trivial modification of code you wrote. Thanks, Mark On Jul 10, 10:51 am, "Stephen C. Gilardi" wrote: > On Jul 10, 2009, at 9:22 AM, markgunnels wrote: > > > I wanted to recommend the fo

Re: clojure.contrib.sql - docallable method

2009-07-10 Thread Stephen C. Gilardi
On Jul 10, 2009, at 11:05 AM, markgunnels wrote: That name sounds much better than mine and sorry for breaking process. The code was definitely a trivial modification of code you wrote. In all the fuss over procedure, I see I forgot to thank you for your request and your report of success w

Re: The snake again - Programming Clojure book

2009-07-10 Thread Rowdy Rednose
Actually, it didn't work (apart from having a "not" in there, which I only used for testing). Calling sync directly works, though: (ns clojure.core) (defmacro dosync [& body] `(do (assert (javax.swing.SwingUtilities/isEventDispatchThread)) (sync nil ~...@body))) But can't I somehow

Re: The snake again - Programming Clojure book

2009-07-10 Thread Michael Wood
2009/7/10 Rowdy Rednose : > > Actually, it didn't work (apart from having a "not" in there, which I > only used for testing). > > Calling sync directly works, though: > > (ns clojure.core) > (defmacro dosync [& body] >  `(do >     (assert (javax.swing.SwingUtilities/isEventDispatchThread)) >     (

Re: From Java to Clojure

2009-07-10 Thread Sean Devlin
To quote Benjamin Stewart: ;; the body of this fn should probably be a macro that takes ;; any number of comparisons and or-chain them correctly such that ;; ties cascade to the next comparison and obviates the need for ;; explicit calls to false-if-zero. Does it already exist? This could be do

Re: The snake again - Programming Clojure book

2009-07-10 Thread Michael Wood
2009/7/10 Michael Wood : > 2009/7/10 Rowdy Rednose : >> >> Actually, it didn't work (apart from having a "not" in there, which I >> only used for testing). >> >> Calling sync directly works, though: >> >> (ns clojure.core) >> (defmacro dosync [& body] >>  `(do >>     (assert (javax.swing.SwingUtil

Re: The snake again - Programming Clojure book

2009-07-10 Thread Rowdy Rednose
The idea is to have all existing code (that gets recompiled after my redefinition) benefit from my changes automatically, although I fear it's not considered good style to do this. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Go

Re: The snake again - Programming Clojure book

2009-07-10 Thread Michael Wood
2009/7/10 Rowdy Rednose : > > The idea is to have all existing code (that gets recompiled after my > redefinition) benefit from my changes automatically, although I fear > it's not considered good style to do this. Ah. Well, I've just tried: (in-ns 'clojure.core) (def old-dosync dosync) but it

Re: The snake again - Programming Clojure book

2009-07-10 Thread Laurent PETIT
I think you'll have to retrieve the old dosync corresponding function, and call this function to get the corresponding generated code, and insert this code at the correct place. Note also that I would better use (in-ns 'clojure.core) instead of (ns clojure.core) (ns is reserved for the creation of

Re: The snake again - Programming Clojure book

2009-07-10 Thread Christophe Grand
On Fri, Jul 10, 2009 at 3:44 PM, Rowdy Rednose wrote: > > On Jul 10, 10:28 pm, Stuart Halloway > wrote: > You can rebind macros, but in order to use them you have to compile > > some code again. > > Recompiling would be fine in this case, but how can I rebind macros? eval is evil but... (let

Re: Clojure cheat sheet

2009-07-10 Thread Steve Tayon
Hi all, I uploaded a new revision. What's new? - filled tables with colours (grey version also included) - attempt to categorize zippers and parallel - added and removed a few commands In short, if you like the last revision, you will love this one. As always, suggestions and comments are welc

ArithmeticException with doubles

2009-07-10 Thread John Harrop
This is odd: user=> (/ 1.0 0.0) # Shouldn't it be Double/POSITIVE_INFINITY? --~--~-~--~~~---~--~~ 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 post

Re: ArithmeticException with doubles

2009-07-10 Thread Sean Devlin
A quick java program: public static void main(String[] args) { System.out.println(1.0/0.0); } Infinity On Jul 10, 11:08 am, John Harrop wrote: > This is odd: > user=> (/ 1.0 0.0) > # (NO_SOURCE_FILE:0)> > > Shouldn't it be Double/POSITIVE_INFINITY? --~--~-~--~~~---

Re: Clojure cheat sheet

2009-07-10 Thread Sean Devlin
Okay, I just printed the color version... Damn! This is awesome! I need to find some really heavy paper now, or a laminator machine, or both. Good job. On Jul 10, 10:27 am, Steve Tayon wrote: > Hi all, > > I uploaded a new revision. > > What's new? > - filled tables with colours (grey version

Re: Got a Clojure library?

2009-07-10 Thread Howard Lewis Ship
Library: Cascade URL: http://wiki.github.com/hlship/cascade Author: Howard M. Lewis Ship Category: web License: ASL 2.0 A functional web application framework: 1/10th Tapestry (http://tapestry.apache.org) goodness, 9/10ths Clojure awesomeness. Adapts Tapestry's general approach to templating in

Re: ArithmeticException with doubles

2009-07-10 Thread Daniel Lyons
On Jul 10, 2009, at 12:24 PM, Sean Devlin wrote: > > A quick java program: > > public static void main(String[] args) { >System.out.println(1.0/0.0); > } > > Infinity > > > On Jul 10, 11:08 am, John Harrop wrote: >> This is odd: >> user=> (/ 1.0 0.0) >> #> (NO_SOURCE_FILE:0)> >> >> Shouldn'

Re: ArithmeticException with doubles

2009-07-10 Thread Kevin Downey
On Fri, Jul 10, 2009 at 1:00 PM, Daniel Lyons wrote: > > > On Jul 10, 2009, at 12:24 PM, Sean Devlin wrote: > >> >> A quick java program: >> >> public static void main(String[] args) { >>    System.out.println(1.0/0.0); >> } >> >> Infinity >> >> >> On Jul 10, 11:08 am, John Harrop wrote: >>> This

Re: ArithmeticException with doubles

2009-07-10 Thread Daniel Lyons
On Jul 10, 2009, at 2:05 PM, Kevin Downey wrote: > using math knowledge to answer (corner) cases of the floating point > spec is silly > people using doubles should be able to expect doubles to behave like > doubles I don't think it's silly, but fair enough. — Daniel Lyons --~--~-~

Re: The snake again - Programming Clojure book

2009-07-10 Thread Laurent PETIT
Here is a debugged version: (in-ns 'clojure.core) (let [old-dosync-fn @#'dosync] (defmacro dosync [& body] (let [real-dosync-job (apply old-dosync-fn body)] `(do (assert (javax.swing.SwingUtilites/isEventDispatchThread)) ~real-dosync-job HTH, -- Laurent 2009/7/

Re: ArithmeticException with doubles

2009-07-10 Thread Mike Hinchey
user> (/ (double 1.0) (double 0.0)) Infinity This seems reasonable since by using (double 0.0), you're asking for double-spec "math" rather than math. :) -Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure

Re: AnotherClojureBox new version!

2009-07-10 Thread e
hi, i downloaded it, and I think i followed the config instructions. What am I supposed to run? I double-clicked on WinCommand.exe and got the GUI up. Then I clicked on the Clojure tab, which just printed out "Application closed!!!" I clicked on Clojure 1.0 and Clojure_1.1_alpha ... no error, b

Re: The snake again - Programming Clojure book

2009-07-10 Thread Rowdy Rednose
Awesome! Works great! (After fixing the typo in "SwingUtilites". that is :) --~--~-~--~~~---~--~~ 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

Re: Clojure in Clojure?

2009-07-10 Thread Chouser
On Thu, Jul 9, 2009 at 4:24 PM, John Harrop wrote: > > The difficult thing would be preserving the inability of bad Clojure code to > crash the process, and most especially, providing all of Swing, AWT, JDBC, > JAXP, and all of the rest of the goodies from the Java class library. Being > JVM-hoste

Re: pprint

2009-07-10 Thread Tom Faulhaber
Hey Laurent, Making this more comprehensible is part of my plan for documenting how to create dispatch. You don't really need to understand the whole XP paper to know enough to understand how pretty print works. Let me lay out a quick overview here: High-level concepts Top-level concept: the pr

Re: Clojure in Clojure?

2009-07-10 Thread Tom Faulhaber
> As awesome as this sounds, wouldn't it first require a > native implementation to be created for each language prior to Clojure > in Clojure running on the platform? No, you don't need to write a native port for each platform. Typically, you break the compiler into two broad parts: the platfor