Nested refs conflicting transactions

2012-04-06 Thread Bryce
I have a system that consists of a map, of the rough form {1 [1 2 3] 2 [2 3 4]}. An update to the system chooses a couple random keys, looks them up in the map, does some math with them, and writes two new values. If one or both of the keys don't exist, they need to be created and their values

Re: Avoiding reflection in vector-of

2012-02-13 Thread Bryce
conj (vector) (range 1000)) I'm not totally clear on why conj'ing works and applying vector-of itself does not, but I'm happy it's faster. On Jan 27, 4:17 pm, Bryce fiat.mo...@gmail.com wrote: Unfortunately with that change I still show ~90% of CPU time being spent in Reflector.getMethods

Re: Avoiding reflection in vector-of

2012-01-28 Thread Bryce
Unfortunately with that change I still show ~90% of CPU time being spent in Reflector.getMethods(). On Jan 27, 11:59 am, Michael Wood esiot...@gmail.com wrote: On 25 January 2012 23:30, Bryce fiat.mo...@gmail.com wrote: [...] ;All of these spend most of their time in reflection (apply

Avoiding reflection in vector-of

2012-01-27 Thread Bryce
I'm building a large vector of longs from a lazy seq, and trying to use vector-of in order to reduce the storage requirements. Although there is no reflection warning (and I've turned on *warn-on- reflection*), in my profiler I see that the majority of the time is spent invoking

Using a macro to define a function - nested backquotes?

2010-05-04 Thread Bryce
I have a macro, deriv, that produces an expression, and I'd like to create another macro that turns this into a function. So far I have (defmacro deriv-fn [fn-args exp v degree] `(fn ~fn-args (deriv ~exp ~v ~degree))) Which of course doesn't work, since it considers the output of deriv as a

Re: Using a macro to define a function - nested backquotes?

2010-05-04 Thread Bryce
:40 pm, Bryce fiat.mo...@gmail.com wrote: I have a macro, deriv, that produces an expression, and I'd like to create another macro that turns this into a function.  So far I have (defmacro deriv-fn [fn-args exp v degree]   `(fn ~fn-args (deriv ~exp ~v ~degree))) Which of course doesn't

Re: Using a macro to define a function - nested backquotes?

2010-05-04 Thread Bryce
Huh, that is artful. Looks like I need to get my dev environment in shape so I can keep up with the changes! On May 4, 6:57 pm, liebke lie...@gmail.com wrote: The output is different because you're using my version of the defn-fn macro, which I checked in late this afternoon. (def f

Multimethods vs. cond?

2010-02-11 Thread Bryce
I'm wondering what the rationale is for using multimethods vs. cond, and where it's best to use either? Multimethods seem to be very seldom used, usually to dispatch on type, but I can see advantages to using data to dynamically define only the methods you need, rather than having

Run expression, with particular functions replaced

2010-02-04 Thread Bryce
I want to create a macro that takes an expression, and runs it against a collection after replacing a bunch of function calls via the replace function. Something like this: (def a {'+ '*}) (def b '(+ a b)) (defmacro substituteFuncs [replacelist expresn target] (#((replace replacelist expresn)

Re: Run expression, with particular functions replaced

2010-02-04 Thread Bryce
3. Making your example work would necessitate discovering which of the symbols in the (+ a b) form are to be treated as formal arguments. In this case, the answer would be a (to be bound to 3) and b (to be bound to 4). In general, that's very nearly impossible, as any symbol not in your

Eval troubles

2010-01-21 Thread Bryce
I'm a clojure newbie, but bear with me; I'm trying to save an expression that contains a function I've defined earlier, and then selectively evaluate it later. (The idea is that I will swap out the function later in the code). Something like (defn y [a b] (+ a b)) (def x '(y 1 2)) (defn -main