Re: Feature idea: meta-macros

2010-09-16 Thread Christophe Grand
Hi, On Wed, Sep 15, 2010 at 8:52 PM, Luke VanderHart luke.vanderh...@gmail.comwrote: Oh, you're right, of course. Still, that doesn't quite meet the case I described, since the bindings won't effect any spawned threads/agents. (alter-var-root #'sql log-around) then -- You received this

Re: Feature idea: meta-macros

2010-09-16 Thread Laurent PETIT
2010/9/16 Christophe Grand christo...@cgrand.net Hi, On Wed, Sep 15, 2010 at 8:52 PM, Luke VanderHart luke.vanderh...@gmail.com wrote: Oh, you're right, of course. Still, that doesn't quite meet the case I described, since the bindings won't effect any spawned threads/agents.

Re: simplest graphics?

2010-09-16 Thread Michael Gardner
On Sep 15, 2010, at 10:15 PM, Lee Spector wrote: Also, this would have a smaller impact but I'm curious about it: is there a way to treat method names as data and then make calls to them, as one can with clojure functions? Then I could pass things like fillRect, or map rect to fillRect,

Re: simplest graphics?

2010-09-16 Thread Christophe Grand
Hi Lee, On Thu, Sep 16, 2010 at 5:15 AM, Lee Spector lspec...@hampshire.edu wrote: Also, this would have a smaller impact but I'm curious about it: is there a way to treat method names as data and then make calls to them, as one can with clojure functions? Then I could pass things like

Re: logging

2010-09-16 Thread lprefontaine
We use common logging with a thin Clojure layer around it. It allows us to have different behaviors in dev pre-prod and production. We avoid the hassle of configuring log4j in dev. The default implementation (simple logging) is more than enough most of the time. In prod, we specify the log4j

Re: ClassCastException: class to interface

2010-09-16 Thread JonnyB
Thank you very much, for your quick reply! At least, i can be sure now, that in principle it should be working. What i wanna do is wrap the jMonkeyEngine3. The hello world example (http://jmonkeyengine.org/wiki/doku.php/ jme3:beginner:hello_simpleapplication) works fine (code below). But when i

inline vs extended types

2010-09-16 Thread SIdhant Godiwala
Hey guys, I'm having some issues with defining types using deftype and would really appreciate some help. Inspired by Mark Engelberg's PersistentPriorityMap http://github.com/clojure/clojure-contrib/blob/master/modules/priority-map/src/main/clojure/clojure/contrib/priority_map.clj, I

Re: partition-starting-every : yet another partition function

2010-09-16 Thread Gijs S.
This answers neither question 1 nor 2, but there is a function from the map, filter and reduce family of higher order functions that is applicable to this problem. The function is called unfold and is the opposite of reduce (see http://en.wikipedia.org/wiki/Anamorphism). An unfold builds a

thinking in clojure

2010-09-16 Thread Michael Ossareh
Hi Guys, One of the things that has struck me about clojure, by virtue of being a lisp, is the concision of the code - I really find it very attractive. However yesterday I found something that I couldn't work out how to do in a concise manner. Clearly commenting the code was a priority once I

Re: thinking in clojure

2010-09-16 Thread David Nolen
On Wed, Sep 15, 2010 at 2:48 PM, Michael Ossareh ossa...@gmail.com wrote: Hi Guys, One of the things that has struck me about clojure, by virtue of being a lisp, is the concision of the code - I really find it very attractive. However yesterday I found something that I couldn't work out how

Re: thinking in clojure

2010-09-16 Thread Mike Meyer
On Wed, 15 Sep 2010 11:48:09 -0700 Michael Ossareh ossa...@gmail.com wrote: Hi Guys, One of the things that has struck me about clojure, by virtue of being a lisp, is the concision of the code - I really find it very attractive. However yesterday I found something that I couldn't work out

Re: thinking in clojure

2010-09-16 Thread Laurent PETIT
Something along those lines : (def t { 0 {:title some :meetings [ :d1 ]} 2 {:title some2 :meetings [ :d2 ]}}) user= (pprint (update-in t [1] (fnil update-in {:title title :meetings []}) [:meetings] (comp vec concat) [:d1 :d2]int (update-in t [1] (fnil update-in {:title title :meetings []})

Re: thinking in clojure

2010-09-16 Thread Meikel Brandmeyer
Hi, maybe this does what you want. I'm not sure, since you add the new meeting to *all* meetings? And where does the :title come from when you add a new meeting? I assume you have a map of a meeting title and a meeting and want to add this to the corresponding entry in the data map. If the

Re: thinking in clojure

2010-09-16 Thread Meikel Brandmeyer
Hi, On 16 Sep., 15:36, Meikel Brandmeyer m...@kotka.de wrote:   (if (not (nil? (next collection) You can save the nil?. (if (not (next collection))) will also work. nil is logically false. And of course this should be (if (next collection)). The not belongs to the You can save part.

Re: ClassCastException: class to interface

2010-09-16 Thread Michael Wood
On 15 September 2010 05:31, JonnyB stoned-jo...@gmx.net wrote: Thank you very much, for your quick reply! At least, i can be sure now, that in principle it should be working. What i wanna do is wrap the jMonkeyEngine3. The hello world example (http://jmonkeyengine.org/wiki/doku.php/

Re: inline vs extended types

2010-09-16 Thread Meikel Brandmeyer
Hi, On 15 Sep., 12:55, SIdhant Godiwala sidhant.godiw...@gmail.com wrote: Is there any way to define the MultiMap protocol inline with the clashing methods? How could there be one? The compiler cannot decide which method to call. Although their name is the same the could have completely

Re: partition-starting-every : yet another partition function

2010-09-16 Thread Nicolas Oury
I think that unfold (or co-reduce, or generate) should find its way in contrib. I am not sure we need finished arg though. The traditional finish in the seq family is nil. My own version of unfold: (defn unfold (unfold seed grow) use the seed and a function grow that returns an element and

Re: thinking in clojure

2010-09-16 Thread Laurent PETIT
2010/9/16 Meikel Brandmeyer m...@kotka.de Hi Laurent, On 16 Sep., 15:54, Laurent PETIT laurent.pe...@gmail.com wrote: you don't like my one-liner ? :-) I saw your message only after I sent mine. :) (update-in coll [k] (fnil update-in *default-value*) [:meetings] (comp vec concat)

Re: missing queue function in core?

2010-09-16 Thread Sean Devlin
+1 On Sep 15, 3:00 pm, grignaak grign...@gmail.com wrote: Does it seem odd to anyone else that this function is missing in core? I propose it gets added. (defn queue  ([] clojure.lang.PersistentQueue/EMPTY )  ([x] (conj (queue) x))  ([x y] (conj (queue x) y))  ([x y more] (into (queue x

Re: Talk at QCon SP

2010-09-16 Thread Vivek Khurana
On Sep 14, 3:49 am, Pedro Teixeira pedr...@gmail.com wrote: Last night, I had the chance to talk about some of the technologies I've put together in a recent project. In particular, it's about mixing clojure + cqrs + event sourcing + cep. I made slides available

Re: thinking in clojure

2010-09-16 Thread Btsai
My poor brain can't handle nested calls to update-in, so this is what I came up with: (defn add-meetings [data k meetings] (cond (nil? (data k)) (assoc data k {:title title :meetings meetings}) :else (update-in data [k :meetings] concat meetings))) On Sep 16, 8:53 am, Laurent PETIT

Re: missing queue function in core?

2010-09-16 Thread nickikt
I thought it was odd too so I think something that makes this easier would be good. On Sep 15, 9:00 pm, grignaak grign...@gmail.com wrote: Does it seem odd to anyone else that this function is missing in core? I propose it gets added. (defn queue  ([] clojure.lang.PersistentQueue/EMPTY )  

Re: thinking in clojure

2010-09-16 Thread Laurent PETIT
So nested calls to update-in are needed in order to be able to provide a specific default value, everytime just having an empty map created isn't sufficient. So instead of (update-in {} [:a :b] identity) which returns {:a {:b nil}} , you can break the key path at :a so that the default value if

Re: thinking in clojure

2010-09-16 Thread Laurent PETIT
And note that the pattern works at any level, and is easily readable, since update-in flattens the arguments of the modifying function : If you want to touch the path [:a :b :c :d] and provide specific default values at each level if the key is not found, it's as simple as : (update-in coll

Re: thinking in clojure

2010-09-16 Thread Btsai
That pattern will be a great addition to the toolbox, thank you :) On Sep 16, 9:58 am, Laurent PETIT laurent.pe...@gmail.com wrote: And note that the pattern works at any level, and is easily readable, since update-in flattens the arguments of the modifying function : If you want to touch the

Re: simplest graphics?

2010-09-16 Thread Alan
I think you may have misunderstood the first suggestion I made, about keeping (shape, color) pairs in your atomic vector. I really meant java.awt.Shape and java.awt.Color objects, rather than a symbol (keyword is better as Christophe suggests) and a bunch of numbers. Like so: (defn render-shape [g

Re: simplest graphics?

2010-09-16 Thread Lee Spector
On Sep 16, 2010, at 12:13 PM, Alan wrote: I think you may have misunderstood the first suggestion I made, about keeping (shape, color) pairs in your atomic vector. I really meant java.awt.Shape and java.awt.Color objects, rather than a symbol (keyword is better as Christophe suggests) and a

Re: partition-starting-every : yet another partition function

2010-09-16 Thread Chouser
On Fri, Sep 10, 2010 at 4:26 PM, Matt Smith m0sm...@gmail.com wrote: problem: convert a collection [1 2 0 1 2 3 0 1 2 3 0 0 1 2] into partitions like: ((1 2) (0 1 2 3) (0 1 2 3) (0) (0 1 2)) In this case, start each partition on a 0. I looked at the various partition functions but none of

Re: practical clojure

2010-09-16 Thread Stuart Sierra
Thanks! Glad you liked the book. -S On Sep 14, 8:37 am, faenvie fanny.aen...@gmx.de wrote: i just emerged from a whirlwind read through 'practical clojure'. i like this book very much. it's a very well structured, carefully written book. kind of a minimalistic approach but minimalistic in