Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Boris Mizhen - 迷阵
> +1. I can't imagine any use case for looking up a whole [key, value] pair in > a hash-map. Actually this is quite useful when you want to do something for each value and need to know the key as well - for example copy some key/value pairs to another map Boris > > -- > You received this message

Re: Would it be possible to make a "dumped" clojure, a la dumped emacs?

2010-04-03 Thread Boris Mizhen - 迷阵
I wonder what is the current state of Clojure @ Android? Is 1.1 running without modifications? If someone is running it, could you share your build.xml and/or any tips? Thank you, Boris On Tue, Mar 23, 2010 at 4:24 PM, Alex Coventry wrote: > My impression from reading Remco van 't Veer's posts

Please share your thoughts on dependency injection

2010-02-08 Thread Boris Mizhen - 迷阵
Hello all, I am playing with the idea of a little library for dependency injection. The idea is to declare injectable values as metadata-to-function map. I started with a sketch of what the client code may look like. Please let me know what you think. Thank you, Boris Dependency declaration cod

Re: Request for Discussion: user created reader macros

2009-08-14 Thread Boris Mizhen - 迷阵
> Clojure spells this #_ instead of / and it is indeed > implemented as a (builtin) reader macro. Nice, thanks! :) > > --Chouser > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: Request for Discussion: user created reader macros

2009-08-14 Thread Boris Mizhen - 迷阵
One thing that I would like to see implemented seems like a good candidate for a reader macro... I find it useful to have a way to comment out an expression by prefixing it with some symbol. I.E. if a '/' before an expression is an expression comment, it is easy to experiment with code: (foo

Re: Transient Data Structures

2009-08-04 Thread Boris Mizhen - 迷阵
> As a second point, I don't like the introduction of assoc!, conj!, > etc.  It just strikes me as another bug to have (oh, right, I need > assoc! not assoc...). At least you will get a very clear error, I think it's possible to get a compile time error if you are dealing with a local. It will be

Re: Improving Clojure's primitive handling (warning: not thought through)

2009-08-04 Thread Boris Mizhen - 迷阵
> Second, the caching is a barrier to escape analysis. Since rather than > seeing a freshly-boxed integer 42, which can be optimized away, the > compiler sees a branch into cache lookup code that returns something > the compiler cannot know, thus it can't get rid of the lookup. Rich, please pardon

Re: Improving Clojure's primitive handling (warning: not thought through)

2009-08-04 Thread Boris Mizhen - 迷阵
>> I don't think this is true if you take closures into account. > > I hadn't thought about closures.  I can see how closures can increase > the number of primitive holder objects but I don't see that they > inviolate the approach.  It's possible that closures would explode the > size of the objec

Re: Improving Clojure's primitive handling (warning: not thought through)

2009-08-04 Thread Boris Mizhen - 迷阵
> You might want to do this with a custom classes, not a one-element > array, because you want to be able to tell if this is your hack or > just someone is passing a one-element array ... Crossed in the air :) Another question - at what point do the objects return to the pool? It seems to me tha

Re: Improving Clojure's primitive handling (warning: not thought through)

2009-08-04 Thread Boris Mizhen - 迷阵
You are suggesting creating mutable boxed numbers with an object pool. You might want to do this with a custom classes, not a one-element array, because you want to be able to tell if this is your hack or just someone is passing a one-element array ... > Once the threadlocal cache is of sufficie

Re: performance concerns (again)

2009-06-05 Thread Boris Mizhen - 迷阵
Try also visualvm (comes with jdk 1.6 ) https://visualvm.dev.java.net/ Boris On Fri, Jun 5, 2009 at 5:22 PM, Jonah Benton wrote: > > Hi Robert, > > I haven't been able to dig into Clojure/JVM/GC details, so I can't > speak in particular about problems e.g. with the ants application, but > there

Re: Interest in creating a NYC Clojure user group?

2009-06-04 Thread Boris Mizhen - 迷阵
I would attend from time to time, but there is lispnyc group http://www.lispnyc.org/home.clp I think it makes more sense to join them - for network effects :) Boris On Thu, Jun 4, 2009 at 12:09 PM, Eric Thorsen wrote: > > I went to the Bay Area Clojure group meeting last night which was > great

Re: Scoping question

2009-05-27 Thread Boris Mizhen - 迷阵
Makes sense, thanks! On Wed, May 27, 2009 at 11:30 AM, Konrad Hinsen wrote: > > On May 27, 2009, at 17:11, Boris Mizhen - 迷阵 wrote: > >> It seems to me that the first would be immune to redefining what >> closure/core.let means at the point where f is invoked, while the &g

Re: Scoping question

2009-05-27 Thread Boris Mizhen - 迷阵
It seems to me that the first would be immune to redefining what closure/core.let means at the point where f is invoked, while the second one would not be. I was unable to actually redefine closure/core.let - probably because it is a macro. But some function was used in place of let, than it coul

Re: Help with Type Hint

2009-05-14 Thread Boris Mizhen - 迷阵
Please correct me if I'm wrong, but my understanding is that Clojure compiler can produce bytecode equivalent to compiled Java code. I think the right approach would be to figure out how to do this in Clojure for the cases like this. Rich? Boris On Thu, May 14, 2009 at 2:25 PM, tmountain wrot

Re: String.getBytes does not translate to byte[]?

2009-05-13 Thread Boris Mizhen - 迷阵
> Well, under the covers the str function applies the java "toString" > method to any passed in object and hence the result could for some > reason be different to the original String object passed in. I think > this could occur if the object subclasses String, but has a different > representation

learning clojure: macro for importing all static public methods of a Java class

2009-05-01 Thread Boris Mizhen
Hello all, below is the code for an utility macro. It wraps all public static functions of a class in closure functions and imports them into the current namespace. Clojure name will be prefix-'method name'. Example: (import-static \"foo\" java.lang.Math) And yes, I saw static import from contr

Re: learning clojure, converting a sequence with repetitions to a multi-map

2009-04-29 Thread Boris Mizhen
Thanks Jason. merge-with seems to be made to support a function like this, I wonder where is the slowdown coming from? Is apply slow? I named your version seq-to-multimap2. The timing results are below: user> (def a (reverse (take 10 (iterate (fn [x] (rand-int 100)) 1 #'user

Re: learning clojure, converting a sequence with repetitions to a multi-map

2009-04-29 Thread Boris Mizhen
ained by applying key-fn to elements of s and values are sequences of all elements of s with a given key" [s key-fn] (reduce (fn [m el] (let [key (key-fn el)] (assoc m key (conj (m key []) el {} s)) Boris On Apr 28, 5:31 pm, Christophe Grand wrote: > Hi Boris,

Re: learning clojure, converting a sequence with repetitions to a multi-map

2009-04-28 Thread Boris Mizhen
ld return a map or a list of lists, that all > depends on what you want to use it for.  Here's a nice demonstration: > > user> (seq-to-multimap (range 1 15) #(mod % 5)) > {0 [5 10], 4 [4 9 14], 3 [3 8 13], 2 [2 7 12], 1 [1 6 11]} > > -SS > > On Apr 28, 4:19 pm

learning clojure, converting a sequence with repetitions to a multi-map

2009-04-28 Thread Boris Mizhen
Hello all, I am starting to learn clojure. I would appreciate comments on the utility function below. Coding style, idiomatic Clojure, comment style, efficiency, naming conventions, indentations (used slime) ... anything I should improve :) (defn seq-to-multimap [s key-fn] "takes a sequence s

Re: areduce flaw

2009-04-28 Thread Boris Mizhen
Thanks Rich, > What's correct is what is documented here: http://clojure.org/java_interop RTFM is still very relevant :) Boris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

Re: areduce flaw

2009-04-27 Thread Boris Mizhen
Thanks to all who replied. To summarize what I learned - Clojure has a special form (. ) to *call* java functions, but does not have concept of a *value* corresponding to a java function. This makes Java functions a second class citizen :) In addition special forms are expanded in the first pos

Re: areduce flaw

2009-04-27 Thread Boris Mizhen
, > > Am 27.04.2009 um 23:17 schrieb Boris Mizhen: > > > ((comp #(Math/abs %) +) -3 -4) => 7 > > > How can I pass a static java function to another function? > > Here you already gave the answer to your question. Wrap it in > a Clojure fn/#(). > > > A

Re: areduce flaw

2009-04-27 Thread Boris Mizhen
e this must be supplied, but perhaps a macro can be created that results in a function that would capture this and call the member function appropriately ... Thank you, Boris On Apr 27, 4:26 pm, Boris Mizhen wrote: > Hello all, > It seems to me that areduce can not be used with an anonymo

areduce flaw

2009-04-27 Thread Boris Mizhen
Hello all, It seems to me that areduce can not be used with an anonymous array. Consider: (areduce (.. System getProperties values toArray) i r 0 (some_expression)) It seems to me that there is no way to get i'th element of the array in (some_expression) other than let'-ing it first. It would be