Re: Parsing parameters in clojure.core

2010-03-25 Thread Per Vognsen
It would be nice if the compiler handled these things with greater cleverness. In the mean time, some macros might be in order. I'd also like to add that clojure.core is not generally an exemplar of style. :) -Per On Wed, Mar 24, 2010 at 11:58 PM, Sean Devlin francoisdev...@gmail.com wrote:

Re: ANN: labrepl, making Clojure more accessible

2010-03-25 Thread Rob Wolfe
On 25 Mar, 01:16, Mark Engelberg mark.engelb...@gmail.com wrote: I tried following Rob Wolfe's zip file instructions.  The bin\lein deps command seemed to work fine, but when I then invoked bin\repl, I got the following error: [...]

Re: Beginning Clojure. Recursion

2010-03-25 Thread Jarkko Oranen
jfr wrote: Hello, I've just started to play a little bit with clojure to get a feel for the language. It seems to be quite interesting (and it's a relief to leave my clumsy IDE behind and use Emacs). Concerning immutable data: Is the following code ok or should (must) I use transients as

Re: Can't call public method of non-public class

2010-03-25 Thread atucker
Is this it? http://www.assembla.com/spaces/clojure/tickets/259 On Mar 23, 8:26 pm, Mark J. Reed markjr...@gmail.com wrote: As far as I can tell, you're doing nothing wrong and just hitting a bug in Clojure.  Which is still in 1.2.0-master... On Tue, Mar 23, 2010 at 11:43 AM, Konstantin

Re: Nubie Question

2010-03-25 Thread WoodHacker
I thank all the people who have sent me solutions to my Conj problem. Unfortunately, none of them seem to work. The issue is adding a value to a defined vector - (def savedColors [black, white]) One solution was given as: (swap! savedColors conj newcolor) This produces still the following

Re: Nubie Question

2010-03-25 Thread Per Vognsen
On Thu, Mar 25, 2010 at 6:52 PM, WoodHacker ramsa...@comcast.net wrote: I thank all the people who have sent me solutions to my Conj problem.   Unfortunately, none of them seem to work. The issue is adding a value to a defined vector - (def savedColors [black, white]) One solution was given

Re: Named arguments in HEAD and prettier default arguments for :keys destructuring

2010-03-25 Thread Stefan Kamphausen
Hi, I've no idea whether this is reasonable but when I read your post suddenly the following thought appeared... What if defn would accept either a vector for the parameters or a map? (defn foo {:dont know :what for} ;; ... ) I did no deeper thinking on this at all, er, skip the deeper, I

Benefit of declarative functional UI in Clojure?

2010-03-25 Thread Sophie
Would a Clojure app benefit sigificantly from a declarative functional UI along the lines of Lunascript http://www.asana.com/luna or FlapJax http://www.flapjax-lang.org/ ? The results look quite impressive ... but I don't have much to compare to in Clojure. I am relatively new to both Clojure and

Re: Can't call public method of non-public class

2010-03-25 Thread Mark J. Reed
That's the one. But the solution given by the bug reporter doesn't address the case that came up on this thread, since it's not the class of the invocant but the types of the parameters that prevent the match from being found. On Thu, Mar 25, 2010 at 7:06 AM, atucker agjf.tuc...@googlemail.com

Re: Named arguments in HEAD and prettier default arguments for :keys destructuring

2010-03-25 Thread Laurent PETIT
Hi, Interesting. Seems more readable, more DRY, indeed. Especially if this becomes idiomatic for optional named arguments ... And the general case could be: (defn funkymonkey [x y z {:keys [[a -1] [b -2] [c -3]], d :d, e [:e -4], :or {b -3, g -6}} [x y z a b c]) ? Which leads to the

Re: web starting clojure apps without Java code

2010-03-25 Thread Eugen Dück
I fixed a couple of other issues, most of which show only on Windows. You should see Kanjis now on the right-hand side when drawing. Eugen On Mar 23, 5:30 pm, Zmitro Lapcjonak idob...@gmail.com wrote: On Mar 17, 4:56 pm, Eugen Dück eu...@dueck.org wrote: The complete jnlp can be found

Re: Nubie Question

2010-03-25 Thread Mark J. Reed
Right. Let's make this clear: outside of the Java interoperability stuff, you cannot change the value of a variable in Clojure. Ever. All the data types are immutable; you can only build new values on top of existing ones, not modify the old ones. When you conj something onto a vector, it

Re: Parsing parameters in clojure.core

2010-03-25 Thread Sean Devlin
I agreed with you until I had to go over every single line of the thing, in order. It actually reads pretty well from top to bottom. Then again, some functions are by necessity just plain nasty. On Mar 25, 2:02 am, Per Vognsen per.vogn...@gmail.com wrote: It would be nice if the compiler

database management: curing lock issues

2010-03-25 Thread Scott
Question on best practices on handling SQL database concurrency issues I am pmapping a evaluation to a long list (which calls a computationally intense script) from within clojure. The script itself is designed to be completely free of concurrency side-effects. During the evaluation, several

Re: database management: curing lock issues

2010-03-25 Thread Joop Kiefte
Isn't programming not all about cheating the computer in doing what you want it to do? In the book programming clojure you can find an example with locks as well. 2010/3/25 Scott sbuck...@gmail.com Question on best practices on handling SQL database concurrency issues I am pmapping a

Re: database management: curing lock issues

2010-03-25 Thread Scott
id prefer best practices if possible typically, cheating has consequences down the line On Mar 25, 10:43 am, Joop Kiefte iko...@gmail.com wrote: Isn't programming not all about cheating the computer in doing what you want it to do? In the book programming clojure you can find an example with

Re: database management: curing lock issues

2010-03-25 Thread Per Vognsen
Are the writes commutative? Since you are using pmap, I presume so. In that case, you could funnel the writes through an agent serving as a queue. -Per On Thu, Mar 25, 2010 at 9:59 PM, Scott sbuck...@gmail.com wrote: id prefer best practices if possible typically, cheating has consequences

Re: database management: curing lock issues

2010-03-25 Thread Meikel Brandmeyer
Hi, maybe you can put finished work packages into a Queue and have a (different) thread reading them from the queue and writing them to the database linearly. So the workers don't have to know about the database and the DB writer doesn't have to care for the computation. Since you can't write to

Re: Beginning Clojure. Recursion

2010-03-25 Thread jfr
Ok, I just looked at frequencies as Miki suggested. (reduce #(assoc %1 %2 (inc (get %1 %2 0))) {} [One Two Two Three Three Three]) would be more like it. Thanks for the infos... -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group,

Re: Beginning Clojure. Recursion

2010-03-25 Thread jfr
Thanks I will take a look at it .Neverless, the idea was to write my own code ;-) You can also use frequencies from c.c.seq-utils (http:// richhickey.github.com/clojure-contrib/seq-api.html#clojure.contrib.seq/ frequencies) HTH, -- Miki -- You received this message because you are

Re: database management: curing lock issues

2010-03-25 Thread Joonas Pulakka
I would suggest using a more concurrency-aware database. I've had luck with H2 (http://www.h2database.com/). It supports mixed local and remote connections in a thread-safe manner. Additionally it supports simple clustering, sounds like you could have use for such. Best Regards, Joonas -- You

Re: database management: curing lock issues

2010-03-25 Thread prhlava
Is it as simple as moving to a better database, such as mySQL? PostgreSQL is considerably better (even than MySQL, which still uses locks AFAIK) for anything concurrent. The PostgreSQL is using multiple version concurrency (MVC) approach - the same approach the clojure STM is using. The

Re: database management: curing lock issues

2010-03-25 Thread Scott
thanks for your suggestions two clear options 1) agents and queued transactions 2) MVC enabled databases (postgresql, h2 (neat project)) Ill try the first option and see how it scales, and worst case move to the second Thanks again Scott On Mar 25, 12:47 pm, prhlava prhl...@googlemail.com

Re: Clojure/LLVM

2010-03-25 Thread Jeff Heon
I know it's not Clojure, but you can at least scratch the Lisp on the iP* itch. Scheme for the iPhone: http://jlongster.com/software/iphone/scheme-iphone-example/ http://jlongster.com/blog/2010/02/23/farmageddon/ -- You received this message because you are subscribed to the Google Groups

Choosing a Clojure build tool

2010-03-25 Thread Chas Emerick
I published a blog post earlier today, along with a short screencast that might be of interest: Like any group of super-smart programmers using a relatively new language, a lot of folks in the Clojure community have looked at existing build tools (the JVM space is the relevant one here,

Re: Choosing a Clojure build tool

2010-03-25 Thread Rob Wolfe
Chas Emerick cemer...@snowtide.com writes: I published a blog post earlier today, along with a short screencast that might be of interest: Like any group of super-smart programmers using a relatively new language, a lot of folks in the Clojure community have looked at existing build tools

Re: Choosing a Clojure build tool

2010-03-25 Thread Brian Carper
On Mar 25, 11:55 am, Chas Emerick cemer...@snowtide.com wrote: I published a blog post earlier today, along with a short screencast   that might be of interest: Like any group of super-smart programmers using a relatively new   language, a lot of folks in the Clojure community have looked at  

Re: Choosing a Clojure build tool

2010-03-25 Thread Chas Emerick
On Mar 25, 2010, at 6:08 PM, Rob Wolfe wrote: No, XML is not the worst thing (at least for me). The real problem is here: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html I'm not sure what you're referring to there. :-) Let's suppose that from time to time

Re: Choosing a Clojure build tool

2010-03-25 Thread Heinz N. Gies
On Mar 25, 2010, at 19:55 , Chas Emerick wrote: I published a blog post earlier today, along with a short screencast that might be of interest: Like any group of super-smart programmers using a relatively new language, a lot of folks in the Clojure community have looked at existing build

converting long string to number

2010-03-25 Thread Glen Rubin
I am trying to convert a long string of numbers to a number, but get a java.lang.numberformatexception My long string of numbers has new line characters in it, so I am filtering out the newline characters before converting it back to a string. Then I try to use Integer. on it but get the above

Re: Choosing a Clojure build tool

2010-03-25 Thread Chas Emerick
Brian, FWIW, I'd claim that maven does deliver on all five points you list. Of note is that it absolutely is IDE-agnostic (I used NetBeans in the screencast because that's what I use -- you can load up maven-defined projects in Eclipse and IntelliJ just as easily). I'm not an emacs

Re: converting long string to number

2010-03-25 Thread Chas Emerick
Glen, You want (java.math.BigInteger. 2342343...). java.lang.Integer is limited to 2^31-1. - Chas On Mar 25, 2010, at 6:40 PM, Glen Rubin wrote: I am trying to convert a long string of numbers to a number, but get a java.lang.numberformatexception My long string of numbers has new line

Re: Help optimizing array-to-integer operation?

2010-03-25 Thread Raph
On Mar 24, 10:57 am, Mark J. Reed markjr...@gmail.com wrote: On Tue, Mar 23, 2010 at 8:19 PM, Raph mart...@gmail.com wrote: (My opinion, anyway.I think a byte should be 8 bits and I should be able to use all of them.) Er, it is, and you can.  A Java byte still gives you all 8 bits' worth

Re: Why I have chosen not to employ clojure

2010-03-25 Thread Timothy Pratley
Clojure can be used in so many different ways. I can't think of any other language where I have so many varied integration options. The flexibility is confusing and frustrating, but I much prefer its presence than absence. :) I'm glad I stuck with it. -- You received this message because you are

Re: Why I have chosen not to employ clojure

2010-03-25 Thread Mark Derricutt
I was thinking it might be interesting to see if we could integrate Bespin Embedded in labrepl, having a nice web based syntax highlighting editor thats consistent on platforms could be quite cool. -- Pull me down under... On Wed, Mar 24, 2010 at 4:26 AM, Stuart Halloway

Re: Choosing a Clojure build tool

2010-03-25 Thread Mark J. Reed
On Thu, Mar 25, 2010 at 6:17 PM, Brian Carper briancar...@gmail.com wrote: Ruby: gem install X Perl: perl -MCPAN -e shell, then install X If you're just installing CPAN module X, then on most installations all you need to run is this: cpan X You can still go into the interactive shell if

referencing an atom inside a function used for swapping

2010-03-25 Thread strattonbrazil
I have a function that I use for adding a JPanel to a ui atom. When I call swap! that ui atom is sent to that function I call with the swap! on and is dereferenced inside the function so I don't need to call @ui on it. However, I want to add listeners to my JPanel that can affect that atom, but

Re: referencing an atom inside a function used for swapping

2010-03-25 Thread Mark J. Reed
I would just pass the atom and move the @ inside the function... On Thursday, March 25, 2010, strattonbrazil strattonbra...@gmail.com wrote: I have a function that I use for adding a JPanel to a ui atom.  When I call swap! that ui atom is sent to that function I call with the swap! on and is

Re: Choosing a Clojure build tool

2010-03-25 Thread Seth
I am in complete agreement! Clojure continues to hinder itself by not providing an official executable. java -cp clojure.jar was good enough for Clojure 0.9, but that's not where it is anymore. Even simple things like submitting bug reports would be helped by having a default clj executable. It

Re: Choosing a Clojure build tool

2010-03-25 Thread Mark Derricutt
For whats it worth here - IntelliJ IDEA will automatically add maven dependencies to you pom.xml file for unknown classes ( in java source, not the clojure plugin - yet), for example if you type com.cemerick.Foo in your source, and its an unknown class, the intention dialog gives you options of

Re: converting long string to number

2010-03-25 Thread Per Vognsen
Though it might not be the best option here, the Clojure reader is always ready to serve: user (type (read-string 123)) java.lang.Integer user (type (read-string 123123123123123)) java.lang.Long user (type (read-string 123123123123123123123123123123123123)) java.math.BigInteger Of course, it

Re: converting long string to number

2010-03-25 Thread Richard Newman
Of course, it might also pose a bit of a security threat: user (read-string #=(println \I OWN YOU NOW!\)) I OWN YOU NOW! nil :) user= (binding [*read-eval* false] (read-string #=(println \I OWN YOU NOW!\))) java.lang.RuntimeException: java.lang.Exception: EvalReader not allowed when

Re: converting long string to number

2010-03-25 Thread Mark Engelberg
Another unadvertised function that is useful to be aware of is clojure.lang.Numbers/reduce which will simplify a number to its most simple type. I often find that I want to use some BigInteger function, but then it is important to turn it back into a typical Clojure number at the end. For

Re: converting long string to number

2010-03-25 Thread Per Vognsen
In those hills yonder in the lands of Common Lisp, it's usually considered good practice to blast the entire read table save for what you need when you deal with untrusted data. Barring that, a better option might be a more modular reader: read-number, read-symbol, etc. -Per On Fri, Mar 26, 2010

Re: converting long string to number

2010-03-25 Thread Richard Newman
In those hills yonder in the lands of Common Lisp, it's usually considered good practice to blast the entire read table save for what you need when you deal with untrusted data. Barring that, a better option might be a more modular reader: read-number, read-symbol, etc. Clojure doesn't have a

concurrency and rand-int

2010-03-25 Thread Lee Spector
I'm trying to track down the reason that I sometimes see a lot of concurrency in my system (up to 1200% CPU utilization on a dual quadcore mac that also has some kind of hyperthreading, allegedly allowing a maximum of 1600% CPU) while other times it gets stuck at around 100-200%. My system (a

Re: concurrency and rand-int

2010-03-25 Thread Per Vognsen
Clojure calls out to Java's java.lang.Math.Random: This method is properly synchronized to allow correct use by more than one thread. However, if many threads need to generate pseudorandom numbers at a great rate, it may reduce contention for each thread to have its own pseudorandom-number

Re: concurrency and rand-int

2010-03-25 Thread Chas Emerick
Hi Lee, Indeed -- from the docs for Math.random(): This method is properly synchronized to allow correct use by more than one thread. However, if many threads need to generate pseudorandom numbers at a great rate, it may reduce contention for each thread to have its own

Re: referencing an atom inside a function used for swapping

2010-03-25 Thread Josh Stratton
I would just pass the atom and move the @ inside the function... But the non-atom is automatically dereferenced and sent to the respective function when I use swap! So unless there's another function to alter atoms, I'm going to have the dereferenced version there no matter what, right? On

Re: referencing an atom inside a function used for swapping

2010-03-25 Thread Mark J. Reed
Ah, right, this is the function called from swap!. So move the listener stuff out of your swap function and into the function that calls swap! instead? On Thu, Mar 25, 2010 at 11:02 PM, Josh Stratton strattonbra...@gmail.com wrote: I would just pass the atom and move the @ inside the

^C behaviour on Leopard (OS X 10.5.8)?

2010-03-25 Thread Douglas Philips
I've been using clojure 1.1.0 (via MacPorts clojure+rlwrap) and every time I type Control-C, it kills closure and dumps me back at my shell. Is that what is supposed to happen? Is there some other keystroke I should be using that will interrupt clojure and put me back at the clojure

Re: ^C behaviour on Leopard (OS X 10.5.8)?

2010-03-25 Thread Per Vognsen
Look at clojure.contrib.repl-utils/add-break-thread!: http://richhickey.github.com/clojure-contrib/repl-utils-api.html -Per On Fri, Mar 26, 2010 at 10:20 AM, Douglas Philips d...@mac.com wrote: I've been using clojure 1.1.0 (via MacPorts clojure+rlwrap) and every time I type Control-C, it

Re: concurrency and rand-int

2010-03-25 Thread Andrzej
As others have pointed out using per-thread java.util.Random objects is probably the best way to go in this particular case. However, I'm curious if the following code could give any speed gain on your machine: (defn rand-seq [] (repeatedly #(. Math (random (def rand-seq-ref (ref

Re: Choosing a Clojure build tool

2010-03-25 Thread Per Vognsen
One of the weirdest things coming to the Java world is to witness what strange things people take for granted should be in the build tool. All the example features you mention in your article are convenient, but I don't see why they belong in the build tool. They should be completely separate

Re: ^C behaviour on Leopard (OS X 10.5.8)?

2010-03-25 Thread Douglas Philips
On 2010 Mar 25, at 11:29 PM, Per Vognsen wrote: Look at clojure.contrib.repl-utils/add-break-thread!: http://richhickey.github.com/clojure-contrib/repl-utils-api.html Nice. Now I have to figure out how to get a clojure rc file! :) -Doug -- You received this message because you are

Re: concurrency and rand-int

2010-03-25 Thread Chas Emerick
I was going to suggest something similar using seque in an atom, but in neither case (using an atom or a ref) is the contention going to be minimized -- just shifted from the AtomicLong in java.util.Random to the now-app-level atom or ref. - Chas On Mar 26, 2010, at 12:30 AM, Andrzej

Re: ^C behaviour on Leopard (OS X 10.5.8)?

2010-03-25 Thread Per Vognsen
You can put a user.clj file in your class path. -Per On Fri, Mar 26, 2010 at 11:42 AM, Douglas Philips d...@mac.com wrote: On 2010 Mar 25, at 11:29 PM, Per Vognsen wrote: Look at clojure.contrib.repl-utils/add-break-thread!: http://richhickey.github.com/clojure-contrib/repl-utils-api.html

Re: Choosing a Clojure build tool

2010-03-25 Thread Chas Emerick
Because they're common processes that are ideally built once, and then reused with minor variation. Library reuse is generally considered to be a good thing in software development, so it strikes me as odd that many think that such practices should stop at the build's edge, as it were.

Re: Choosing a Clojure build tool

2010-03-25 Thread Per Vognsen
On Fri, Mar 26, 2010 at 11:50 AM, Chas Emerick cemer...@snowtide.com wrote: Because they're common processes that are ideally built once, and then reused with minor variation.  Library reuse is generally considered to be a good thing in software development, so it strikes me as odd that many