Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-27 Thread Mark Engelberg
Thanks for the info. I'd need to research how clojure.lang.BigInt differs from java.math.BigInteger, but I'm sure that adding the extra case for BigInt in the multimethods wouldn't be too hard. I'm still stumped as to why expt and sqrt would be 100x slower. My first thought is that the

Re: Some programs require much more memory in Clojure 1.3 alpha1

2010-09-27 Thread Andy Fingerhut
Hmmm. I did some additional experiments using the JRockit JVM on Windows XP, and JRockit not only has equivalent memory usage for Clojure 1.2 and 1.3 alpha1, but it can also run these programs with significantly less memory than HotSpot. HotSpot is similar, but not identical, in its

Macro expansion problem

2010-09-27 Thread stefanmuenchow
I am a macro newbie... I want to create a macro that calls a function with a given name and a parameter list on a given object. My first idea was like this: (defmacro call Calls an instance method on a given object with a list of params. [obj method-name params] `(. ~obj ~(symbol

Re: Lazytest 1.0.0 (beta)

2010-09-27 Thread faenvie
i am trying to use lazytest with eclipse + ccw ? lazytest.watch does not work for me so far. so i run my lazytests via: (ns myapp.runtests (:require lazytest.runner.console lazytest.color lazytest.report.nested)) ; switch ansi-coloring off (lazytest.color/set-colorize false)

Hiccup with Sequence

2010-09-27 Thread Paul
Hi all, I'm trying to output the items from a sequence into a HTML list using the Hiccup HTML builder, but am having problems. Here is the code I think 'should' work, but nothing after the ':ul' is passed back to the response: (html [:html [:body

Re: Fighting with Emacs ;-)

2010-09-27 Thread psfblair
I found the old thread below, but unfortunately the solution isn't working for me. If I have a foo.clj file in a buffer and evaluate region on (defn foo [] (+ 1 2)) I get #'user/foo in the minibuffer. If I then evaluate region on (foo) I get 3 in the minibuffer. The slime REPL is giving me a

Re: Hiccup with Sequence

2010-09-27 Thread Nicolas Oury
doseq do not return anything. (It is for side-effect only). You might be looking for 'for'. (doc for) - clojure.core/for ([seq-exprs body-expr]) Macro List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more

Re: Macro expansion problem

2010-09-27 Thread Nicolas Oury
Difficult problem. macro are syntactic tools. So they are not made to evaluate things at runtime. You could expand to something that call eval at runtime but it is not a good idea (It involves the compiler at each call) If your (rest alist) is known at macro-expansion time, then it can work but

Re: Lazytest 1.0.0 (beta)

2010-09-27 Thread Laurent PETIT
Hi, 2010/9/27 faenvie fanny.aen...@gmx.de i am trying to use lazytest with eclipse + ccw ? You note that you're using ccw, is that because you have a clue that there could be something related to the lazytest-ccw combo in the issue you're facing ? lazytest.watch does not work for me so

Re: Hiccup with Sequence

2010-09-27 Thread Paul
Nicolas, Yes, that's solved the problem. Many thanks for you swift help. Paul. On Sep 27, 12:12 pm, Nicolas Oury nicolas.o...@gmail.com wrote: doseq do not return anything. (It is for side-effect only). You might be looking for 'for'. (doc for) - clojure.core/for

Re: Some programs require much more memory in Clojure 1.3 alpha1

2010-09-27 Thread Peter Schuller
Anyone know any command line options for HotSpot that make it work harder to compact things down into the smallest space possible, no matter what?  I am aware of several pages of documentation on HotSpot's GC options, and I've been reading some of them, but it is a lot to wade through. There

Re: ANN: Clojure Cookbook

2010-09-27 Thread MarkSwanson
Nice! -- 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 new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to

Re: Lazytest 1.0.0 (beta)

2010-09-27 Thread Stuart Sierra
Don't have any specific suggestion at the moment. I'm planning on adding a REPL runner that will do something similar to the code you posted. -S On Sep 27, 5:52 am, faenvie fanny.aen...@gmx.de wrote: i am trying to use lazytest with eclipse + ccw ? lazytest.watch does not work for me so far.

Re: ANN: Clojure Cookbook

2010-09-27 Thread Tim Daly
There is a movement afoot in the common lisp community to implement quicklisp which is similar to the perl cpan site or debian. It would be useful if there was a quicklisp (or asdf) for Clojure. Thus you could apt-get a library for clojure. Tim Daly On 9/27/2010 1:47 AM, David Sletten wrote:

Re: finding value nearest x

2010-09-27 Thread Glen Rubin
It occurs to me that another way of doing this is to map a new list and then use the min fn. something like: (apply min (map #(Math/abs (- % 136)) xs)) maybe this is better and involves less calculations? On Sep 25, 2:19 pm, Glen Rubin rubing...@gmail.com wrote: min-key looks good!  thx

return index of a value

2010-09-27 Thread Glen Rubin
I have a vector of numbers [0 99 3334 53 2 5 99 2 55 63] I'd like to find the first index of a particular value. For example if the value was 99 then I want to return 1, b/c the index of 99 is 1. I can do this with a loop/recur structure comparing each value in the list to my desired value,

Re: finding value nearest x

2010-09-27 Thread Michael Gardner
On Sep 27, 2010, at 9:28 AM, Glen Rubin wrote: It occurs to me that another way of doing this is to map a new list and then use the min fn. something like: (apply min (map #(Math/abs (- % 136)) xs)) maybe this is better and involves less calculations? That gives you the minimum distance

Re: finding value nearest x

2010-09-27 Thread Glen Rubin
yes correct. but i can write a fn to determine the index of the minimum distance in my new list? that index applied to my original list will give me the value back. and this still would involve fewer calculations i think. On Sep 27, 10:50 am, Michael Gardner gardne...@gmail.com wrote: On Sep

Re: return index of a value

2010-09-27 Thread Stuart Halloway
Hi Glen, Finding the *first* index isn't very Clojurish, what you want is to find *all* the indexes, lazily. Then if you want the first one, just call first. (use '[clojure.contrib.seq-utils :only (positions)]) (positions #{99} [0 99 3334 53 2 5 99 2 55 63]) - (1 6) Cheers, Stu I have a

Re: return index of a value

2010-09-27 Thread Michael Gardner
On Sep 27, 2010, at 9:45 AM, Glen Rubin wrote: I have a vector of numbers [0 99 3334 53 2 5 99 2 55 63] I'd like to find the first index of a particular value. For example if the value was 99 then I want to return 1, b/c the index of 99 is 1. I can do this with a loop/recur structure

Re: finding value nearest x

2010-09-27 Thread Michael Gardner
On Sep 27, 2010, at 9:59 AM, Glen Rubin wrote: yes correct. but i can write a fn to determine the index of the minimum distance in my new list? that index applied to my original list will give me the value back. and this still would involve fewer calculations i think. Do you have a

Re: ANN: Clojure Cookbook

2010-09-27 Thread Diullei Gomes
very good! On Mon, Sep 27, 2010 at 1:12 PM, Tim Daly d...@axiom-developer.org wrote: There is a movement afoot in the common lisp community to implement quicklisp which is similar to the perl cpan site or debian. It would be useful if there was a quicklisp (or asdf) for Clojure. Thus you

Re: finding value nearest x

2010-09-27 Thread Adam Burry
On Sep 25, 11:41 am, Glen Rubin rubing...@gmail.com wrote: I have a list of numbers and I want to find the one that is closest to 136.  Is there an operator for performing this kind of operation or do I need to to do it algorithmically? I think the normal way to do this is a k-d tree:

Re: Macro expansion problem

2010-09-27 Thread stefanmuenchow
Thanks for your reply :) The context: I am developing a wrapper generator that takes a Java class and generates a Clojure wrapper, with a function for each method etc. The purpose is to have nice wrappers, so your code is cleaner as with all that Java calls. And it can ba a basis for more

Re: finding value nearest x

2010-09-27 Thread Glen Rubin
ok, thx. just trying to keep myself to a high standard while learning this stuff ;) On Sep 27, 11:12 am, Michael Gardner gardne...@gmail.com wrote: On Sep 27, 2010, at 9:59 AM, Glen Rubin wrote: yes correct.  but i can write a fn to determine the index of the minimum distance in my new

Re: return index of a value

2010-09-27 Thread Glen Rubin
interesting! thx guys! On Sep 27, 10:45 am, Glen Rubin rubing...@gmail.com wrote: I have a vector of numbers [0 99 3334 53 2 5 99 2 55 63] I'd like to find the first index of a particular value.  For example if the value was 99 then I want to return 1, b/c the index of 99 is 1.  I can do

exception thrown when passing in nil parameter

2010-09-27 Thread Glen Rubin
I have a function that will accept 3 or 4 parameters. Another function I have calls it and passes in 4 arguments. Sometimes, the 4th argument is nil and this causes an error, instead of just calling the main function as if I passed in 3 arguments. Meaning the main function sees a 4th parameter

Re: exception thrown when passing in nil parameter

2010-09-27 Thread Alan
(defn f ([a b c] ...) ([a b c d] (if d ... (f a b c Not the prettiest solution, I'll grant you; I'm sure someone will come along with something better. But this will work. On Sep 27, 11:13 am, Glen Rubin rubing...@gmail.com wrote: I have a function that will accept 3

How often do you use REPL?

2010-09-27 Thread Christian Guimaraes
It's a noob question... I know But in my studies I use REPL 80% of the coding time. More advanced users still uses REPL so many times? thanks. -- christian guimaraes -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

Re: How often do you use REPL?

2010-09-27 Thread Linus Ericsson
Why not? The only thing I found very practical (even though it does not yet work 100% (like autoloading the open code in the repl) for me) is the possibility to fire of longer commands and function definitions (or the like) in Slime (or vi-equivalent). The repl is a great way to debug your

Re: Fighting with Emacs ;-)

2010-09-27 Thread Linus Ericsson
I recognize that one. The repl haven't loaded the file your editing. My (temporary) solution is to do a (load-file the file your editing) after each edit that I want to debug, but that's a bit boring. I guess there is some kind of reload feature somewhere... /Linus 2010/9/27 psfblair

Re: How often do you use REPL?

2010-09-27 Thread Laurent PETIT
A lot. By that, I mean that probably 80% to 100% of the time the REPL is running waiting for your command. And what may change is that you may more and more send code to the REPL from your favorite editor. 2 flavors : * keep the full control on what is emitted to the REPL. There are shortcuts

Re: How often do you use REPL?

2010-09-27 Thread Wilson MacGyver
I use REPL quite a bit. Especially if I'm quickly trying to throw something together. I'd use vimclojure and REPL. In intelliJ, I use REPL for brain storm and testing. On Mon, Sep 27, 2010 at 3:14 PM, Christian Guimaraes cguimaraes...@gmail.com wrote: It's a noob question... I know But in

Possible to avoid reflection in this deftype in 1.3 alpha1?

2010-09-27 Thread Andy Fingerhut
The following program compiles and runs perfectly fine in both 1.2 and 1.3 alpha1. It has no reflection warnings in 1.2, but it does in 1.3 alpha1. I have tried several variations, but I haven't yet been able to figure out how to write type declarations that avoid reflection in 1.3

Re: Fighting with Emacs ;-)

2010-09-27 Thread Alan
C-c C-k in the .clj buffer is easier and equivalent (or at least very similar) On Sep 27, 12:27 pm, Linus Ericsson oscarlinuserics...@gmail.com wrote: I recognize that one. The repl haven't loaded the file your editing. My (temporary) solution is to do a (load-file the file your editing)

Re: exception thrown when passing in nil parameter

2010-09-27 Thread Stuart Sierra
Here's one popular form: (defn foo ([a b c] (foo a b c nil)) ([a b c d] (if d ...))) Most multi-arity functions have the same behavior for every arity, with some default argument values. -S On Sep 27, 2:13 pm, Glen Rubin rubing...@gmail.com wrote: I have a function that will accept 3 or 4

Re: Possible to avoid reflection in this deftype in 1.3 alpha1?

2010-09-27 Thread Stuart Halloway
That's weird. I see no reflection warnings when loading this on 1.3 alpha 1. Stu The following program compiles and runs perfectly fine in both 1.2 and 1.3 alpha1. It has no reflection warnings in 1.2, but it does in 1.3 alpha1. I have tried several variations, but I haven't yet been

Interop question concerning optional args

2010-09-27 Thread JonathanBelolo
While toying with the Sesame2.3 library, I've come across the following behavior for the first time. This is taken from the api doc for org.openrdf.repository.base.RepositoryConnectionBase: add(Resource subject, URI predicate, Value object, Resource... contexts) Adds a statement with

Re: Possible to avoid reflection in this deftype in 1.3 alpha1?

2010-09-27 Thread Andy Fingerhut
OK, so I happened to stumble across a fix to my program, but I still wonder whether this is intentional behavior in 1.3 alpha1 or not. If I change the name 'nbody' in these lines: (let [^Body nbody other dx (- x (.x nbody)) ; first reflection warning here

Re: Possible to avoid reflection in this deftype in 1.3 alpha1?

2010-09-27 Thread Andy Fingerhut
I don't know if it makes a difference, but I was doing AOT compilation on a file nbody.clj containing the program in my message. I replied to my own message with a workaround that it seems to be related to the variable 'nbody' having the same name as the one in the 'ns' declaration.

Re: Interop question concerning optional args

2010-09-27 Thread ataggart
The vararg at the end of the method is just syntactic sugar for an array, so the add method actually takes 4 args, the last being a Resource array. The java compiler just replaces missing varargs with an empty array. My guess is that the reflection mechanisms in the compiler just look at

Re: ANN: Clojure Cookbook

2010-09-27 Thread Daniel Pittman
Tim Daly d...@axiom-developer.org writes: There is a movement afoot in the common lisp community to implement quicklisp which is similar to the perl cpan site or debian. It would be useful if there was a quicklisp (or asdf) for Clojure. Thus you could apt-get a library for clojure. FWIW,

Re: ANN: Clojure Cookbook

2010-09-27 Thread Scott Jaderholm
Daniel, If you install lein-search (http://clojars.org/lein-search or http://github.com/Licenser/lein-search) you can do searches like that. lein search mail If you put it in ~/.lein/plugins it will work for all your lein projects and you can even use it to add what you find to your project.clj

question regarding macro (ab)usage

2010-09-27 Thread gaz jones
hi, apologies if this is a long question, i would appreciate some guidance here. i am creating a clojure wrapper around a rather verbose low latency messaging framework. the main things you can do are publish messages, receive messages, initialize sources and receivers etc. all are done through

Re: How often do you use REPL?

2010-09-27 Thread ngocdaothanh
cake (http://github.com/ninjudd/cake) has the tab completion feature. Because this is very useful, I wonder if this feature should be added to leiningen or Clojure itself. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send