Running in VisualVM suggests that % of Used Heap is actually very
less. So the problem is that GC isn't running often enough, so the JVM
has to keep allocating more memory.
By problem I meant, in my case, of too much memory consumption.
Odd. I'd expect the JVM to run a GC immediately before
Andreas, How are you running that? Also what do you see in the heap
dump and what is the jvm heap size?
--
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
Note that posts from new members are
I've been using ccw for a while now and it works perfectly as
advertised. Plus the new 0.2.0 version looks to be really promising. I
invite all ccw users to give their inputs.
What's bugging is not that you faced a problem or that ccw didn't work
as you expected, what's disturbing is how you
To me this looks totally fine, max-key should keep at most two
sequences in memory. I don't think there should be any difference
between the non-lazy and lazy versions as the depth of cseq is ~500.
The non-lazy version works for me (no heap error) for inputs 1M, 2M,
4M, but for 4M the java
Here's one way to use eclipse + ccw + lein
1. Download latest eclipse helios. Go to market place and search for
counter clockwise plugin. Install the latest stable.
2. Create a new Clojure project. Delete the 4 jars it provides :) (yes
that's right delete them).
3. Install lein
@Bill,
If you have a REPL open you can just run the test as a zero arg
function.
(ns 'abc)
(detest xyz ...)
user= (abc/xyz)
--
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
Note that
Yes that compareTo doesn't define a total order on your class. I think
you are missing a clause in cond:
(cond
(= sr sr2) 0
(= (.lik sr) (.lik s2)) return something based on quasi-isomorphic
( (.lik sr) (.lik sr2)) -1
:default 1)
I think you should implement quasi-isomorphic as a
+1 on partial with no args !
I have a doubt: using partial conveys the intent, but with automatic
currying one may get confused between partial application
function call, no?
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send
The functions get-in, assoc-in, update-in are really useful. Just
wanted to share a thoughts.
user= (def m {:a {:b {:c 10 :c1 20} :b1 90} :a1 100})
#'user/m
1. Lets see the behavior of these functions in the corner case of
empty keyseq:
user= (get-in m [])
{:a {:b {:c 10, :c1 20}, :b1 90}, :a1
Hi Brian,
Can you explain this in more detail :
I didn't have the laziness problem. I don't know if that was by accident or
because Midje applies an #'eagerly function before checking.
Because it seems that if code has a laziness problem, Midje will
actually hide it in tests?
Thanks.
--
(defn dec-or-dissoc! [key]
(dosync
(let [n (@*counts* key)]
(if ( 1 n)
(alter *counts* assoc key (dec n))
(alter *counts* dissoc key)
Is it true that in that case, one would have to use ensure to make the
operation correct?
I don't think ensure is necessary
Hi Tim,
How about compare?
user= (compare a b)
-1
user= (compare b b)
0
user= (compare b a)
1
user= (compare 1 2)
-1
user= (compare 2 2)
0
user= (compare 2 1)
1
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
This is a good question and I'm not sure of the right answer or if
there is one. Personally, if I were exposing an API I would use the
io! macro for sure. Even otherwise its a good convention to follow.
On Nov 30, 9:06 am, Alex Baranosky alexander.barano...@gmail.com
wrote:
Hi guys,
I've
Hi Michael,
We're in a very similar situation to yours. Here's what we did:
1. 2 back end storage impls rah.storage1, rah.storage2 - these are
private nses.
2. a single storage interface rah.storage for the rest of the business
code. At runtime this decides which of storage1 or 2 to call.
3. Now
I'm also stuck with the same issues: 1. no option to get string keys
2. I don't understand, why do libs go through the trouble of
downcasing ?
Having said that I totally agree with the point Ryan makes: A
greater feature of clojure is its extensibility. What I am after is a
generalization of
Hi Islon,
Records already implement java.io.Serializable. So this is working:
(ns record-serialization)
(defrecord R [x y])
(defn test-serialization
[]
(with-open [oos (java.io.ObjectOutputStream.
(java.io.FileOutputStream. tmp))]
(.writeObject oos (R. 12 42)))
(with-open [ois
May I ask a heretic question: Why don't you specify the contract in the
docstring of the protocol?
Yes Meikel that is exactly what I have right now. Just trying to learn
and stir up a discussion here :)
Most times you'll just do fine by passing 'something' to Coolness
functions and expect
Christophe, Is it reasonable to assume that atleast the documentation
should be modified to reflect the situation?
--
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
Note that posts from new
Hi Tom,
I might not be even remotely qualified but since I'm interested and
find the idea cool, so here's my take:
- has anyone already experimented with a toy STM in Clojure for didactic
purposes?
No idea :)
- what would be a good resource to start such a design from? (my current plan
1. How to combine protocols?
For example I have protocols walks, talks, sleeps, now how might I
come up with an abstraction which walks-talks-and-sleeps ? In Java
one might create an interface which extends multiple interfaces.
Although getting an instance which walks-talks-and-sleeps is made
Clojure 1.2.0
1:1 user=
1:2 user=
1:3 user= (deftype T [] Object (equals [this o] (if (instance? T o)
true false)))
user.T
1:4 user= (def t (T.))
#'user/t
1:5 user= (.equals t t)
false
1:6 user= (deftype T [] Object (equals [this o] (if (= T (class o))
true false)))
user.T
1:7 user= (def t (T.))
I would guess the problem is referring to T inside the deftype.
This also works:
(deftype T [] Object (equals [this o] (if (= T (class o)) true
false)))
But as Meikel said hope that this is not the end of the story.
--
You received this message because you are subscribed to the Google
Groups
AFAIK, it is not possible. You must implement all the different protocols.
It might look desapointing, but on the other hand it is not necessary.
(As there is no static typing in Clojure)
What is your use-case?
Current use case is that I want an abstraction which comprises of a
set of
Hi Alex, Can we have a section: Clojure - What's next? Dishes out
some details links for the next versions and ideas.
--
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
Note that posts from
generates namespace (and package) dependency graphs at various levels
- complete src, single ns, single package. Additionally the graph
itself is available in many forms - Clojure map, .xml, .dot, .png
The code itself is a bit ugly old but it works on both unix and
windows - http://github.com/na-ka-na
Hi,
Please explain this!
code path for using vars is now *much* faster for the common case, and you
must explicitly ask for :dynamic bindability
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
+1, besides adding transients, protocols 1.2 features, can we also
have a Future section after the Reference section?
--
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
Note that posts from new
I've been wondering about having let over defn, I have the following
concerns -
1. Not recommended in the docs
http://clojure.org/special_forms#Special%20Forms--%28def%20symbol%20init?%29
says - Using def to modify the root value of a var at other than the
top level is usually an indication that
@Alan
I'm trying to understand why you find the solution you gave gross
I could construct all the objects and have a single global map, with
mappings for both set-id=[objects] and object=set-id, but this seems
kinda gross and obscures what is actually meant (objects belong to
sets) with
I follow this thread, but haven't read Clojure's source. I have a
similar question -
http://groups.google.com/group/clojure/browse_thread/thread/46415b89c7b311f6,
but haven't got any responses yet.
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To
These seem like good changes to me! Any plans to push?
--
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
Note that posts from new members are moderated - please be patient with your
first
Hi,
I have two refs a1, a2. One thread modifies a1, another modifies a2.
Sample code: http://gist.github.com/556679
If I don't ensure any ref in the transaction, the code runs in ~ 0.2
ms.
$ java -cp lib/clojure-1.2.0.jar\;src clojure.main -e (require 'tt)
(tt/transaction-simul {:ensure2
For the program, I know that when processing a character, I do not
need the previous result. All I need is the current character, and I
can return a function that acts on the result. I'm not sure if this is
simple to implement in a functional way.
Actually my understanding says that you need
So, it appears the (read-line) consumes the Clojure form (in-ns
'test.readln) probably stacked by CCW (at least I didn't type that!)
Yup you're right, CCW typed that, you may disable that feature from
the Windows Preferences Clojure Editor.
Thanks
--
You received this message because you
@Meikal,
Hi, I get what you mean. Consider the following func -
(defn r
[n lazy?]
(.println System/out (str Called (r n )))
(let [r-lazy-seq (fn r-lazy-seq [i n]
(lazy-seq
(when ( i n)
(.println System/out (str Realizing
Awesome awesome new features !!
Yes, when does windows support stop being experimental ?
Even though one of the new features is -
* Added experimental Windows support.
Has anyone tried lein 1.2 on windows (with the lein.bat on
http://github.com/technomancy/leiningen) ?
--
You received this
@Chouser
Sorry, my above post was directed as a question to you. Have to stop
being lazy while posting atleast :) !
--
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
Note that posts from new
(for [a (r 2), b (r 3)] [a b])
; produces:
range 2
(range 3
[0 0] [0 1] range 3
[0 2] [1 0] [1 1] [1 2])
Why does (r 2) get evaluated before the seq is needed ?
= (def k (for [a (r 2), b (r 3)] [a b]) )
range 2
#'a/k
- Thanks
--
You received
To my naive inexperienced eyes, there doesn't seem to be something
obviously wrong with your code.
Since FOR returns a lazy sequence of the results, is this function
safe? (Seeing that it is not side-effect free?)
I'm not getting this, do you foresee any safety issues? I think that
the logs
I'm also facing the same problem -
(let [handler (agent 50)
a (agent 42
:error-handler
(fn [_ ex]
(do
(println Inside agent a error handler fn (Thread/
currentThread))
(send handler
(fn [_] (do
How about this (using only map, reduce) -
user= (def data1 [[:a1 :b1 :c1]
[:a1 :b1 :c2]
[:a1 :b2 :c3]
[:a1 :b2 :c4]
[:a2 :b3 :c5]
[:a2 :b3 :c6]
[:a2 :b4 :c7]
[:a2 :b4 :c8]])
user= (pprint
(reduce
(fn f [tree
My favorite option of those proposed is:
+, *, -, inc, dec auto-promote.
loop/recur is changed so that primitive bindings are boxed.
+',*',-',inc',dec' give error upon overflow.
A new construct, loop', is introduced that doesn't box primitives and
enforces recur with primitive upon penalty
Since the stubs are around, you can also run JavaDoc.
The stubs don't need to be saved. In the Maven world, they are part of
the build, not source files.
On Jun 4, 8:03 am, ka sancha...@gmail.com wrote:
@Jason
I'm supplying a Java API (implemented in Clojure) so needed a solution
quickly
Hi Zak,
It seems very weird that my version of fac changes performance
characteristics on my machine and not yours (OS/hardware dependent?).
Can you tell your hardware configuration, esp. number of physical and
logical cores? I am planning next to leave out using pmap and just try
to run the
Hi Zak,
I tried your example on my i7 (4 physical cores, 8 logical); here are
the results -
1:298 user= (time (do (doall (map fac (take 10 (repeat 5
nil))
Elapsed time: 54166.665145 msecs
1:300 user= (time (do (doall (pmap fac (take 10 (repeat 5
nil))
Elapsed time: 27418.26344
Hi Clojurians,
I have some conceptual questions on the sequence abstraction. I
understand that (seq coll) will give me a sequence.
coll maybe be a list, vector, map, set, LazySeq or nil.
1. In case coll is a LazySeq why does (seq coll) realize its first
element? I thought seq just did a type
I've also added a :class-doc key to the macro -
(gen-class+javadoc
:class-doc Class Docs
ul li One /li li Two /li /ul
:name a.b.c.MyCoolClass
:methods [
#^{:static true} [method1
[clojure.lang.PersistentArrayMap] int]
Oops didn't know that Rich had already answered. Google seems to
think that our posts are commutative :/ (often they're not, or are
they? I can't take a stand on this) and just uses the commute fn
instead of using alter and failing the transaction (informing us); but
it does allow for more
This looks cool. I'll definitely give it a try in my next project.
Any chance to get it integrated somehow with eclipse ccw?
- 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
Note
Hi Tim,
Thanks! for such a detailed response. Really got things in
perspective for me, my thinking yet isn't of such large scale.
So you say literate programming is for those who are writing code that
will live for decades to come and that writing literate programs takes
~3x resources.
Is
It would be voodoo magic :) and totally awesome might I say if (= a
(drop 4 a)) returned true immediately!
- 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
Note that posts from new
My 2 cents, I read about transients for the first time (why is the
page not linked from clojure.org?) and they seem very promising at a
first glance.
I'm not sure if I agree with Michael's idea of having the same
functions for transients and persistents both. Functions should have
easy,
Stefan Kamphausen writes:
sorry, I'm a little late. However, to me it is not clear what the
trim functions shall do. If they become a replacement for chomp they
are clearly misnamed. In many applications and languages (like Excel,
several SQL variants, oh, and Java, ...) trim means
Tim,
I don't know much about either lisp or latex :). But it looks like a
really neat idea at a first thought to me. Have two remarks-
1. From the developer's pov - I'm not sure how the developer, who is
accustomed to looking at just code + some comments, will manage
working with the book. But
You may use reduce, as follows:
(let [r (java.util.Random.)
f (fn [el] (.nextBoolean r))]
(def pred f))
(reduce (fn [m el]
(let [k (pred el)]
(assoc-in m [k] (conj (m k) el
{true [] false []}
(range 10))
Thanks
--
You received this message
As Steve said, better look at the combinatorics-api.
As for your original code, the idea you have gives all permutations
not combinations! Few changes will make it functioning -
(defn permutations [n coll]
(if (= n 1)
(map #(vector %) coll)
(for [el coll nlis (permutations (- n
1:6 user= (use '[clojure.set])
nil
1:7 user= (reduce union #{} #{#{[3 2] [5 4] [3 3] } #{[4 3] [5 4] [3
3] } #{[3 2] [2 2] [3 3] } } )
#{[3 2] [4 3] [5 4] [2 2] [3 3]}
1:8 user=
Thx
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this
Hi, any responses?
--
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
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group,
Hi all,
I've written an API in Clojure to be consumed by people working in the
Java world. Now most of these people haven't even heard of Clojure;
but all they care about is 1) a working API and 2) with nice
documentation.
1) Something about the API - I tried out various things, types,
records,
@Michael,
There is already a monitor mechanism available in Clojure via the
'locking' macro or more primitive monitor-enter, monitor-exit. So in
your case all you have to implement is the blocking behavior, I'm not
sure if it can be already done somehow using just Clojure elements.
The above code
If add-watch is not what you want because you want the consumers to
have a life of their own, then does something like this work? -
(def my-hash (ref {}))
(def new-keys (ref #{}))
(defn produce []
(let [new-key (rand-int 10)
new-val P]
(Thread/sleep 100)
(dosync
(alter
pm, ka sancha...@gmail.com wrote:
If add-watch is not what you want because you want the consumers to
have a life of their own, then does something like this work? -
(def my-hash (ref {}))
(def new-keys (ref #{}))
(defn produce []
(let [new-key (rand-int 10)
new-val P
You can get rid of the I/O in the transaction and still see a consistent
snapshot by simply return the contents of the refs.
(defn report-status
[]
(apply println (dosync [...@my-hash @new-keys])))
Sincerely
Meikel
--
Isn't ensure necessary? Because http://clojure.org/refs says
+1
On May 7, 2:13 am, Mibu mibu.cloj...@gmail.com wrote:
Am I the only one driven mad by the new auto-appended signature to
every message in this group (You received this message because you
are subscribed...)? It started on April 16th. Is there a way a
moderator can stop it?
--
You
Not wanting to become an uninvited guest to your party :-) ... but do
you mind elaborating .. ?
On May 9, 2:31 am, Base basselh...@gmail.com wrote:
I just replaced 443 lines of java with 61 lines of Clojure.
THANK YOU RICH !!!
--
You received this message because you are subscribed to the
are
constructed ?
2010/4/29 Alex Osborne a...@meshy.org:
ka sancha...@gmail.com writes:
Above I wrote a macro with-open-flexi! ... which I'm planning to use
in my app's API . .. please let me know if there are any bugs /
gotchas / improvements etc...
I didn't get any responses, so does
Hi ppl,
Above I wrote a macro with-open-flexi! ... which I'm planning to use
in my app's API . .. please let me know if there are any bugs /
gotchas / improvements etc...
I didn't get any responses, so does it means there is something so
obviously wrong that you can't even begin where to start
would be useful, if only as syntactic sugar.
On Wed, Apr 21, 2010 at 10:43 AM, ka sancha...@gmail.com wrote:
Thanks all for replies.
Laurent, Alex you guys are right, the problem is only with aesthetics
of nesting / boilerplate. The nesting implementation semantically
expresses exactly
Hi,
I'm using an API to connect to a server which does not provide
constructors, just static methods to get close connections.
How can I do something like ...
(try
(let [conn (API/getConnection ..)]
())
(catch ..)
(finally (if conn (API/closeConnection conn
Problem is that
.closeConnection(conn2);
}
I agree that this code doesn't look good from a purist pov, but any
issues besides that?
- Thanks!
On Apr 21, 4:58 pm, Alex Osborne a...@meshy.org wrote:
ka sancha...@gmail.com writes:
How can I do something like ...
(try
(let [conn (API/getConnection
{$s ~= 'd';}
default {$s ~= 'z';}
}
is $s, 'c', 'Caught number';
};
Thanks!
On Apr 21, 7:05 pm, Alex Osborne a...@meshy.org wrote:
ka sancha...@gmail.com writes:
The whole code gets cluttered with all these try finally (and one
catch) statements.
(try
(let [conn1
I'm trying to make a function which gives the n! permutations of a
vector of n things. Here is my first attempt :
(defn permute
Gives the n! permuations of the input vector of things
[v]
(if (= 1 (count v)) (list [(v 0)])
(loop [i 0 perm '()]
(if (= i (count v))
perm
Thanks, that answers my questions.
--
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
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe
Hi,
I was just wondering if (by now) Open CL has been 'wrapped' by higher
level languages. I came across these from the Khronos site (http://
www.khronos.org/developers/resources/opencl/#timplementations) -
1. http://ruby-opencl.rubyforge.org/
2.
Hi clojure folk,
I'm reading up on clojure from the book 'Programming clojure'. In
chapter 2 there is a statement -
The imperative indexOfAny must deal with several special cases:
null or empty strings, a null or empty set of search characters,
and the absence of a match. These special cases
75 matches
Mail list logo