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
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
,
>
> 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
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
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,
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
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
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,
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
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
> 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
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
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
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
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
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
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
> 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
>> 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
> 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
> 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
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
> 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
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
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
> +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
26 matches
Mail list logo