Idiomatic sub-hashmap

2009-02-13 Thread Adrian Cuthbertson
Hi, I have had need of a sub hash map function and implemented it as follows; (defn sub-hashmap Return a sub map of hmap containing the specified keys. [hmap ks] (reduce (fn [mm k] (assoc mm k (k hmap))) {} ks)) (sub-hashmap {:a 1 :b 2 :c 3} :a :c) ;= {:c 3, :a 1} Is there a similar

Re: Questions about the Enlive template library

2009-02-13 Thread Christophe Grand
Hi Tom, Tom Hickey a écrit : Snippets I think what you have suggested for snippets sounds perfect. I added defsnippet and defsnippets. Setting content escaping Thanks you for explaining the cases here. Having a better idea of what to expect will help in testing further. (I'm still

Re: Idiomatic sub-hashmap

2009-02-13 Thread Timothy Pratley
Yup: select-keys user= (select-keys {:a 1 :b 2 :c 3} [:a :c]) {:c 3, :a 1} Regards, Tim. On Feb 13, 8:01 pm, Adrian Cuthbertson adrian.cuthbert...@gmail.com wrote: Hi, I have had need of a sub hash map function and implemented it as follows; (defn sub-hashmap Return a sub map of hmap

Re: Idiomatic sub-hashmap

2009-02-13 Thread Adrian Cuthbertson
Thanks! On Fri, Feb 13, 2009 at 1:28 PM, Timothy Pratley timothyprat...@gmail.com wrote: Yup: select-keys user= (select-keys {:a 1 :b 2 :c 3} [:a :c]) {:c 3, :a 1} Regards, Tim. On Feb 13, 8:01 pm, Adrian Cuthbertson adrian.cuthbert...@gmail.com wrote: Hi, I have had need of a sub

with-local-vars vs. let

2009-02-13 Thread Mark Volkmann
What are some reasons to use with-local-vars instead of let or binding? -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email

loop [#^Integer c 0] vs. loop [c (int 0)] and optimization question...

2009-02-13 Thread Dimiter malkia Stanev
Hi guys, I'm optimizing a little benchmark called pnpoly, and I was wondering what is the proper way of hinting the compiler for types. In certain cases Clojure accepts for example loop [#^Integer c 0] and in others loop [c (int 0)] - I'm really trying to hint the compiler as best as I can. I'm

Re: with-local-vars vs. let

2009-02-13 Thread Konrad Hinsen
On Feb 13, 2009, at 13:31, Mark Volkmann wrote: What are some reasons to use with-local-vars instead of let or binding? Let just creates bindings for a lexical scope. They cannot be modified at all. Binding and with-local-vars deal with vars, i.e. mutable references. Binding creates a

Re: loop [#^Integer c 0] vs. loop [c (int 0)] and optimization question...

2009-02-13 Thread Laurent PETIT
Hello, I can't manage to get the code from the URL (server timeout) 2009/2/12 Dimiter malkia Stanev mal...@gmail.com Hi guys, I'm optimizing a little benchmark called pnpoly, and I was wondering what is the proper way of hinting the compiler for types. In certain cases Clojure accepts for

Re: loop [#^Integer c 0] vs. loop [c (int 0)] and optimization question...

2009-02-13 Thread Vincent Foley
Dimiter, The latest revision of Clojure is r1278; are you using the Google code trunk? Vincent On Feb 12, 5:35 pm, Dimiter \malkia\ Stanev mal...@gmail.com wrote: Hi guys, I'm optimizing a little benchmark called pnpoly, and I was wondering what is the proper way of hinting the compiler

Re: Issue request: RT.load's don't load if already loaded mechanism breaks :reload-all

2009-02-13 Thread Stephen C. Gilardi
Rich, May I please enter an issue to track the defect that require/use's :reload-all flag is not working properly in Clojure. --Steve On Feb 11, 2009, at 8:01 AM, Stephen C. Gilardi wrote: On Feb 6, 2009, at 8:45 AM, Laurent PETIT wrote: Hello, Does it also mean that the following use

Re: Reflection warnings starting at r1265

2009-02-13 Thread Vincent Foley
Should I add this to the list of issues in the Google Code tracker? Vincent. On Feb 12, 4:15 pm, Vincent Foley vfo...@gmail.com wrote: Hello, I was surprised today to see that my Starcraft replay program became slower when I updated my Clojure working copy.  About a week ago, Chouser

Re: with-local-vars vs. let

2009-02-13 Thread Adrian Cuthbertson
Have a look at compojure - a good example of with-local-vars is where a servlet request is executed. Each (get, post) request occurs in its entirety on a single (jetty or tomcat) thread. The compojure call to the application service function binds the http headers, servlet request parameters,

Re: generated class with overloaded methods

2009-02-13 Thread Christophe Grand
Laurent PETIT a écrit : 2009/2/13 Christophe Grand christo...@cgrand.net mailto:christo...@cgrand.net Laurent PETIT a écrit : Hello, Thanks for having shared that, Do you know if there's a way to overload methods with the same arity, then ?

Re: generated class with overloaded methods

2009-02-13 Thread Laurent PETIT
??? 2009/2/13 Craig McDaniel craig...@gmail.com I just tried it out to be sure. Overloaded methods with the same arity work as expected. Clojure picks the right method to call via reflection. package expmeth; public class ClassA { public void hello() { System.err.println(hello

Re: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel
Christophe, you're right. I tried it and that method also works. I didn't know about that secret feature. (ns expmeth.TestMe (:gen-class :extends expmeth.ClassA :exposes-methods {hello helloSuper})) (defn -hello [this] (.helloSuper this) (println hello from clojure!)) (defn

Re: generated class with overloaded methods

2009-02-13 Thread Laurent PETIT
Thanks Christophe, that's the answer I was hoping to get, If I was twenty years younger, I would just say Clojure roxxXXooRR :-) (well, I think this is supposed to say that clojure is really cool, hope I didn't misunderstood the rooxxXXooRR thing :-) -- Laurent 2009/2/13 Christophe Grand

Re: Reflection warnings starting at r1265

2009-02-13 Thread Rich Hickey
On Feb 13, 9:06 am, Vincent Foley vfo...@gmail.com wrote: Should I add this to the list of issues in the Google Code tracker? No. Those hints were suspect to begin with. .get returns a byte already, and .getShort a short, so those hints shouldn't do anything useful. Similarly, coercing to

Re: generated class with overloaded methods

2009-02-13 Thread Laurent PETIT
Hello , Your example code below is not complete (where's helloSuper definition ?), but I think it does not answer my specific question ? Anyway, it seems that Christophe found the answer. But I don't know if we should use this knowledge, since it is not exposed as an API ? -- Laurent

Re: Issue request: RT.load's don't load if already loaded mechanism breaks :reload-all

2009-02-13 Thread Rich Hickey
On Feb 13, 9:04 am, Stephen C. Gilardi squee...@mac.com wrote: Rich, May I please enter an issue to track the defect that require/use's :reload-all flag is not working properly in Clojure. How does this interact with: http://code.google.com/p/clojure/issues/detail?id=3 Rich

Re: loop [#^Integer c 0] vs. loop [c (int 0)] and optimization question...

2009-02-13 Thread Dimiter malkia Stanev
On Feb 13, 5:35 am, Vincent Foley vfo...@gmail.com wrote: Dimiter, The latest revision of Clojure is r1278; are you using the Google code trunk? Vincent Thanks, Vincent! I kept wondering why I don't see any more versions, I was till on the sourceforge one.

Re: Reflection warnings starting at r1265

2009-02-13 Thread Vincent Foley
Thanks Rich! On Feb 13, 10:01 am, Rich Hickey richhic...@gmail.com wrote: On Feb 13, 9:06 am, Vincent Foley vfo...@gmail.com wrote: Should I add this to the list of issues in the Google Code tracker? No. Those hints were suspect to begin with. .get returns a byte already, and .getShort a

Re: with-local-vars vs. let

2009-02-13 Thread Konrad Hinsen
On Feb 13, 2009, at 15:35, Adrian Cuthbertson wrote: Have a look at compojure - a good example of with-local-vars is where a servlet request is executed. Each (get, post) request occurs in its entirety on a single (jetty or tomcat) thread. The compojure call to the application service

Re: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel
On Feb 13, 9:59 am, Laurent PETIT laurent.pe...@gmail.com wrote: Your example code below is not complete (where's helloSuper definition ?), Yes, it is complete. See :exposes-methods under (doc gen-class). helloSuper is the exposed name for the hello method in the superclass. Clojure creates

Re: generated class with overloaded methods

2009-02-13 Thread Laurent PETIT
Didn't know, thank you again for this knowledge, -- laurent 2009/2/13 Craig McDaniel craig...@gmail.com On Feb 13, 9:59 am, Laurent PETIT laurent.pe...@gmail.com wrote: Your example code below is not complete (where's helloSuper definition ?), Yes, it is complete. See :exposes-methods

Re: generated class with overloaded methods

2009-02-13 Thread Laurent PETIT
Yes, but please note that Christophe's method also solves the problem of defining overloaded methods with different java signatures, but still same name and same arity. I still can't see how your proposed method solves this particular problem ? Regards, -- Laurent 2009/2/13 Craig McDaniel

Re: bug + patch: lazy branch take-while is broken

2009-02-13 Thread Rich Hickey
On Feb 12, 10:20 pm, Chouser chou...@gmail.com wrote: There's a misplaced paren in take-while in the lazy branch. Patch attached. --Chouser Fixed in SVN 1280 - thanks for the report. Rich --~--~-~--~~~---~--~~ You received this message because you are

Syslog

2009-02-13 Thread jim
Has anyone done logging using syslog from clojure or java? Thanks --~--~-~--~~~---~--~~ 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 To unsubscribe from this

Re: A stupid beginners question about Compile

2009-02-13 Thread Mark Volkmann
On Thu, Feb 12, 2009 at 5:09 PM, Laurent PETIT laurent.pe...@gmail.com wrote: In a nutshell (not tested, but nothing should miss, just typos if it doesn't work) : mkdir test-compile cd test-compile mkdir classes mkdir src mkdir src/echo echo (ns echo.test) (defn echo [msg] msg)

Re: Issue request: RT.load's don't load if already loaded mechanism breaks :reload-all

2009-02-13 Thread Stephen C. Gilardi
On Feb 13, 2009, at 10:12 AM, Rich Hickey wrote: On Feb 13, 9:04 am, Stephen C. Gilardi squee...@mac.com wrote: Rich, May I please enter an issue to track the defect that require/use's :reload-all flag is not working properly in Clojure. How does this interact with:

Re: A stupid beginners question about Compile

2009-02-13 Thread Laurent PETIT
2009/2/13 Mark Volkmann r.mark.volkm...@gmail.com On Thu, Feb 12, 2009 at 5:09 PM, Laurent PETIT laurent.pe...@gmail.com wrote: In a nutshell (not tested, but nothing should miss, just typos if it doesn't work) : mkdir test-compile cd test-compile mkdir classes mkdir src mkdir

Re: A stupid beginners question about Compile

2009-02-13 Thread Mark Volkmann
On Fri, Feb 13, 2009 at 10:18 AM, Laurent PETIT laurent.pe...@gmail.com wrote: 2009/2/13 Mark Volkmann r.mark.volkm...@gmail.com On Thu, Feb 12, 2009 at 5:09 PM, Laurent PETIT laurent.pe...@gmail.com wrote: In a nutshell (not tested, but nothing should miss, just typos if it doesn't

Re: A stupid beginners question about Compile

2009-02-13 Thread Laurent PETIT
That's really a matter of conventions. Both work, and you just have to correctly adjust the call to load : 1st layout : src/echo/test.clj src/echo/test/test-part2.clj Then you'll have (ns echo.test (:load test/test-part2) in src/echo/test.clj 2d layout: src/echo/test.clj src/echo/test-part2.clj

Re: with-local-vars vs. let

2009-02-13 Thread Adrian Cuthbertson
What I see in your example is binding, but I don't see with-local- vars anywhere. Or did I misunderstand something? Sorry, I checked the compojure source again and the servlet headers, cookies, etc are wrapped in a with-servlet-vars macro (rather than with-local-vars) which just uses let. The

Useful memory profiling tool

2009-02-13 Thread levand
Determining exactly how much memory objects are using is often desirable, especially since one of Clojure's few flaws (which is the JVM's fault, mostly) is that it can be fairly memory-hungry. So, I took the techniques described in http://www.javaworld.com/javaworld/javatips/jw-javatip130.html,

Re: More Swing Examples

2009-02-13 Thread Emeka
http://clojure.googlegroups.com/web/2c-calculator.clj?gda=GfxNgEMAAAC2LrkjeC7f10uHiY7GOiyxomoTIbx5E_ZvCUIqi7LhkTsFONunm7BW3wPdbl53QhAytiJ-HdGYYcPi_09pl8N7FWLveOaWjzbYnpnkpmxcWg http://www.plt1.com/1070/even-smaller-snake/ --~--~-~--~~~---~--~~ You received this

Re: A stupid beginners question about Compile

2009-02-13 Thread Stephen C. Gilardi
I wonder what the rationale was for making it so namespaces need to be quoted when using in-ns. They don't need to be quoted when using ns. For example, I have (ns com.ociweb.talk (:gen-class)) in one file and (in-ns 'com.ociweb.talk) in another. I guess this is because it's conceivable one

Re: A stupid beginners question about Compile

2009-02-13 Thread Laurent PETIT
2009/2/13 Stephen C. Gilardi squee...@mac.com I wonder what the rationale was for making it so namespaces need to be quoted when using in-ns. They don't need to be quoted when using ns. For example, I have (ns com.ociweb.talk (:gen-class)) in one file and (in-ns 'com.ociweb.talk) in

Re: calling Clojure functions from Java

2009-02-13 Thread Mark Volkmann
On Fri, Feb 13, 2009 at 11:19 AM, Laurent PETIT laurent.pe...@gmail.com wrote: http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java 2009/2/13 Mark Volkmann r.mark.volkm...@gmail.com Can someone point me to documentation on how to invoke Clojure

Re: Questions about the Enlive template library

2009-02-13 Thread Tom Hickey
Hi Christophe, I was not on the latest version (and I now know that the download button on github does not necessarily give you the latest!). I am now seeing the differences in output on descendent updates. I understand about only one rule being applied, and the warning definitely helps to see

eliminating uses of nil punning

2009-02-13 Thread Chouser
In the lazy branch, empty sequences don't always evaluate as false in a boolean context. Tracking down places you've made this assumption can be hard. Attached is a patch that helps by providing a flag, assert-if-lazy-seq. When this flag is on, 'if' is replaced with a new (slower) version that

Re: calling Clojure functions from Java

2009-02-13 Thread Chas Emerick
Mark, If you use the #^{:static true} metadata on a :methods definition in a gen-class spec for your class' implementing namespace, then those fns appear as static functions in the generated Java class: Clojure: (ns bar.Foo (:gen-class :methods [#^{:static true} [stringLength

Re: calling Clojure functions from Java

2009-02-13 Thread Matt Revelle
Mark, In case you were asking how to call a Clojure function from Java without wrapping it, check out clojure.lang.IFn and AFn. For example, say you prefer to write a class in Java but need to accept a Clojure fn as an argument in one of the class methods: public int callFromClojure(IFn

cljc?

2009-02-13 Thread Mark Volkmann
Is there a reason why it would be inadvisable or particularly difficult to create a cljc script, short for Clojure compile, that would take a path to a Clojure source file and compile it to .class files? It seems tedious to have to add :gen-class to the source file, start a REPL, and enter a

Re: cljc?

2009-02-13 Thread Stephen C. Gilardi
On Feb 13, 2009, at 3:47 PM, Mark Volkmann wrote: Is there a reason why it would be inadvisable or particularly difficult to create a cljc script, short for Clojure compile, that would take a path to a Clojure source file and compile it to .class files? It seems tedious to have to add

Re: cljc?

2009-02-13 Thread Mark Volkmann
On Fri, Feb 13, 2009 at 3:00 PM, Stephen C. Gilardi squee...@mac.com wrote: On Feb 13, 2009, at 3:47 PM, Mark Volkmann wrote: Is there a reason why it would be inadvisable or particularly difficult to create a cljc script, short for Clojure compile, that would take a path to a Clojure

Re: cljc?

2009-02-13 Thread chris
It would perhaps be a lot more inefficient. From what I can understand, clojure loads the namespace in question and the actual command to the compiler is write this namespace to here. It checks symbols from other modules and does a very light sort of link step. This requires knowledge of other

Re: A Clojure documentation browser

2009-02-13 Thread Craig Andera
Please consider whether or not you'd like to send in a Contributor Agreement to enable that. If you hurry you could become the first registered Clojure contributor whose last name begins with A. :-) (clojure.org/contributing) OK, I've added the things I want to add, and sent in the agreement,

Re: My SLIME installation diary

2009-02-13 Thread David
I have a small problem with clojure-mode in your setup. Since clojure-mode is autoloaded, it, and SLIME, aren't available until I load a '.clj' file. Starting SLIME, though, doesn't add the SLIME menu to the previously loaded '.clj' buffer (Newly loaded files get the menu, as they should).

Re: My SLIME installation diary

2009-02-13 Thread Phil Hagelberg
David dsieg...@yahoo.com writes: I have a small problem with clojure-mode in your setup. Since clojure-mode is autoloaded, it, and SLIME, aren't available until I load a '.clj' file. Starting SLIME, though, doesn't add the SLIME menu to the previously loaded '.clj' buffer (Newly loaded

Re: cljc?

2009-02-13 Thread Stephen C. Gilardi
On Feb 13, 2009, at 4:10 PM, Mark Volkmann wrote: As far as I know, the classpath only needs clojure.jar, the src directory and the classes directory. Here's an idea. The locations of those could be command-line arguments to the cljc script. They could default to simply src and classes

run clojure on 5,832 cores?

2009-02-13 Thread Raoul Duke
http://sicortex.com/products --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to

Re: run clojure on 5,832 cores?

2009-02-13 Thread Christian Vest Hansen
I see no mention of a JVM being available for those CPUs, but perhaps the no-asm HotSpot can be build with gcc on it. Otherwise, cool gear :) On Fri, Feb 13, 2009 at 11:47 PM, Raoul Duke rao...@gmail.com wrote: http://sicortex.com/products -- Venlig hilsen / Kind regards, Christian

Re: A Clojure documentation browser

2009-02-13 Thread Stephen C. Gilardi
Hi Craig, On Feb 13, 2009, at 4:21 PM, Craig Andera wrote: OK, I've added the things I want to add, and sent in the agreement, which will probably make it to Rich next week. The code is on github [1] - if you want it somewhere else, let me know. I assume someone other than me will be

Re: run clojure on 5,832 cores?

2009-02-13 Thread Stuart Sierra
On Feb 13, 6:13 pm, Christian Vest Hansen karmazi...@gmail.com wrote: I see no mention of a JVM being available for those CPUs, but perhaps the no-asm HotSpot can be build with gcc on it. Looks like they run Linux, so it would probably be possible. This article

New mod code is breaking the contrib unit tests

2009-02-13 Thread Jeffrey Straszheim
I just updated, and the unit tests for mod are breaking. It looks like the new mod only works for ints. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

how to emulate lisp's labels functionality?

2009-02-13 Thread wubbie
Hi, do we have labels equiv. in clojure? The code below is from OnLisp. Trying to convert to clj file, but have minor difficulties. (defun count-instances (obj lsts) (labels ((instances-in (lst) (if (consp lst) (+ (if (eq (car lst) obj) 1 0) (instances-in (cdr lst))) 0)))

Re: how to emulate lisp's labels functionality?

2009-02-13 Thread Phil Hagelberg
wubbie sunj...@gmail.com writes: Hi, do we have labels equiv. in clojure? The code below is from OnLisp. Trying to convert to clj file, but have minor difficulties. You can use let since variables and functions are kept in the same namespace. (defun count-instances (obj lsts) (labels

Re: how to emulate lisp's labels functionality?

2009-02-13 Thread Chouser
On Fri, Feb 13, 2009 at 8:01 PM, Phil Hagelberg p...@hagelb.org wrote: wubbie sunj...@gmail.com writes: Hi, do we have labels equiv. in clojure? The code below is from OnLisp. Trying to convert to clj file, but have minor difficulties. You can use let since variables and functions are kept

Re: run clojure on 5,832 cores?

2009-02-13 Thread Mark H.
SiCortex had a nice booth at Supercomputing '08. They have desktop versions of their machines too. I've heard that the SiCortex machines have a fabulous communication network, but they expect you to use it via their MPI stack. I don't think they offer a shared memory abstraction that the JVM

Re: New mod code is broken

2009-02-13 Thread Stephen C. Gilardi
On Feb 13, 2009, at 7:40 PM, Jeffrey Straszheim wrote: I just updated, and the unit tests for mod are breaking. It looks like the new mod only works for ints. Thanks for the report. I removed the non-integer tests. The new mod isn't working properly though: Testing

Re: Newbie at macros: Manipulating a vector of bindings

2009-02-13 Thread Chouser
On Fri, Feb 13, 2009 at 11:17 PM, samppi rbysam...@gmail.com wrote: I'm trying to write a macro that expands from this: (product-context [n rule0, m rule1)] (rule-maker2 (+ n m)) rule3)) Into this (assume that conc-fn and conc-products are functions): (fn [tokens] (if-let [[remainder#

Re: New mod code is broken

2009-02-13 Thread Chouser
On Sat, Feb 14, 2009 at 12:45 AM, Stephen C. Gilardi squee...@mac.com wrote: The new mod isn't working properly though: Testing clojure.contrib.test-clojure.numbers FAIL in (test-mod) (numbers.clj:104) expected: (= (mod 9 -3) 0) actual: (not (= -3 0))

Re: eliminating uses of nil punning

2009-02-13 Thread Chouser
On Fri, Feb 13, 2009 at 1:30 PM, Chouser chou...@gmail.com wrote: To turn on the flag you need to rebuild clojure with an extra option, like this: ant -Dclojure.assert-if-lazy-seq=please Any non-empty string will do for the value. You will need to set the value at runtime as well. There