Hi,
Am 25.01.2009 um 08:41 schrieb Greg Harman:
This could be a real problem for Clojure. I can think of other
techniques that could easily result in the creation a large number of
anonymous functions that ought to get gc'd after a few ms but
permanently increase memory usage by a significant a
How about compiling a closure tree ?
;; very basic example follows
(defn make+ [param1 param2]
(fn [environement]
(+ (param1 environement) (param2 environement
(defn make* [param1 param2]
(fn [environement]
(* (param1 environement) (param2 environement
(defn make-variable [
Phlex wrote:
> How about compiling a closure tree ?
>
> ;; very basic example follows
>
> (defn make+ [param1 param2]
> (fn [environement]
> (+ (param1 environement) (param2 environement
>
> (defn make* [param1 param2]
> (fn [environement]
> (* (param1 environement) (param2 envir
Zak Wilson a écrit :
> Thanks, Christophe. It works now, and it's fast.
>
> Unfortunately, now I've run in to Nathan's problem. After a few
> thousand generations, resulting in the creation of about half a
> million functions it was using over a gig of memory and died with an
> OutOfMemoryError.
Clojure creates class not for every function call, but for every
function definition.
The PermGen growth you see is the REPL compiling your input, most likely.
On Sun, Jan 25, 2009 at 8:26 AM, Greg Harman wrote:
>
> I'm trying to debug a problem in one of my programs in which PermGen
> usage gr
On Sun, Jan 25, 2009 at 11:13 AM, Christophe Grand
wrote:
> Zak Wilson a écrit :
>> know the JVM very well at all. Are there any ways around this? Are
>> techniques that generate a lot of short-lived functions just not
>> practical in Clojure?
>>
> Yes there are a way around this: permgen memory
Hi all,
I'd like to repeat my request for an example of definline usage; I
feel I've tried everything.
user=> (definline f [x] x)
java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:1)
user=> (definline [x] x)
java.lang.NullPointerException (NO_SOURCE_FILE:2)
user=> (definline (f [x] x))
java.
Hi Anand,
Here is an example from core.clj:
(definline doubles
"Casts to double[]"
[xs] `(. clojure.lang.Numbers doubles ~xs))
As you can see it is using macro magic as you would expect for in-
lining.
Regards,
Tim.
On Jan 25, 11:06 pm, Anand Patil
wrote:
> Hi all,
>
> I'd like to repea
On Sun, Jan 25, 2009 at 7:06 AM, Anand Patil
wrote:
>
> I'd like to repeat my request for an example of definline usage; I
> feel I've tried everything.
I looked into this yesterday, and it seems to me that definline has
been broken since SVN rev 1065. I don't know why the usages of it in
core.
On Jan 23, 10:43 pm, e wrote:
> Just to understand ... 'send-future' works too but you don't think that's
> the way to go?
The Agent send pool has a limited size, so doing recursive calls with
a stack greater than that size will result in a freeze (waiting for
new threads that can't be made ye
On Jan 25, 2009, at 5:13 AM, Christophe Grand wrote:
>
> Zak Wilson a écrit :
>> Thanks, Christophe. It works now, and it's fast.
>>
>> Unfortunately, now I've run in to Nathan's problem. After a few
>> thousand generations, resulting in the creation of about half a
>> million functions it was u
I believe you, but I don't understand why. I'm doing nothing but
evaluate my test function over and over. Since no new functions are
being defined, why would this evaluation use any PermGen?
On Jan 25, 5:57 am, Christian Vest Hansen
wrote:
> Clojure creates class not for every function call, but
When the reader has a top-level expression in the REPL, it gets
evaluated. Evaluation goes through the Compiler which generates
bytecode from your forms. Before the bytecode can be executed, it
needs to be loaded into the JVM, and that happens by wrapping it in a
class and loading that.
On Sun, J
To clarify:
On Sun, Jan 25, 2009 at 3:08 PM, Greg Harman wrote:
>
> I believe you, but I don't understand why. I'm doing nothing but
> evaluate my test function over and over.
Exactly. This input is evaluated and compiled over and over.
> Since no new functions are
> being defined,
The expres
I couldn't find anything in Clojure that would correspond to Common
Lisp's reader conditionals, in particular the extremely useful #-(and)
idiom.
I would like to suggest the inclusion of a reader macro: #* or something
of the kind, that would simply ignore the form right after it. That
would allo
I tried using the zipper data structure and immediately noticed, that
there is a function I need, which isn't there.
I would like to have something like root-loc (with a better name), that
would do exactly what root does, except it would return a tree location,
not just the root node.
Or perhaps
Thanks for the explanation, Meikel.
My statement about anti-pattern was predicated on each call to fn[]
creating a new class - I see from your explanation and from going back
and re-reading Rich's old posts on this topic that I misunderstood it
before. (If it did create a new class each time, I'd
I see, so running (permGen) 10 times from the REPL is not the same as,
say, (dotimes [_ 10] (permGen)), because there's an understood (eval)
around anything executed directly in the REPL.
Thanks.
On Jan 25, 9:33 am, Christian Vest Hansen
wrote:
> When the reader has a top-level expression in th
The IRC channel folks helped me implement what we discovered was
already called "separate" in contribs. My point was to do a partition
that generated the two lists "(passes pred)" and "(fails pred)" in one
pass without recursion.
We ended up with:
(defn filt-rem [pred coll]
(loop [l1 () l2
I think using eval is generally considered an antipattern. It's
generally slow, and it's easy to make confusing code with it.
Phlex - thanks for the suggestion. I may give that a try.
Rich - thanks for the fix. I'm trying it now. It looks like it's not
experiencing any permanent growth, though i
Hi e,
I'm still learning the basics, very much like you( I guess you are ahead of
me in Clojure). However, I have a question for you and not an answer to your
questions. Why do you have doall here (def l1 (doall (take 5 (repeatedly
#(rand-int 3000) . From my little knowledge of Clojure, ta
For those who like me are playing with the stream-enabled branch of
Clojure, there is a new module stream-utils on clojure.contrib:
http://code.google.com/p/clojure-contrib/source/browse/trunk/src/
clojure/contrib/stream-utils.clj
Obviously this is very experimental, and absolutely no
Clojure has that in the comment form: (comment (do (not (eval this
--~--~-~--~~~---~--~~
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
To unsubscribe from
Hi,
Am 25.01.2009 um 17:11 schrieb Zak Wilson:
Clojure has that in the comment form: (comment (do (not (eval this
No. That's not equivalent. comment leaves a nil behind, while #*
would not.
[:a (comment :b) :c] => [:a nil :c]
[:a #* :b :c] => [:a :c]
Sincerely
Meikel
smime.p7s
Descri
I would like to convert the following ruby/rake code to Clojure:
Dir.chdir ENV["CLOJURE_HOME"] do
system "git svn rebase"
system "ant jar"
end
Since Java does not have the notion of a current directory, one way to
go about this would be to modify clojure.contrib.shell-out/sh as
On Sun, Jan 25, 2009 at 8:01 AM, Chouser wrote:
> On Sun, Jan 25, 2009 at 7:06 AM, Anand Patil
> wrote:
>>
>> I'd like to repeat my request for an example of definline usage; I
>> feel I've tried everything.
>
> I looked into this yesterday, and it seems to me that definline has
> been broken sin
What's the typical usage of fn constantly ?
thanks
-sun
--~--~-~--~~~---~--~~
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
To unsubscribe from this group,
I have embedded clojure-swank in my program like so:
(defn ui-start-swank-server
"Start a swank server. I think this prints out
a port number but I am not certain"
[logger-ref]
(with-bindings
(let [fname (.getCanonicalPath (fs-get-temp-file "swank"))]
(start-server fname)
(log
On Sun, Jan 25, 2009 at 11:52 AM, Stuart Halloway
wrote:
>
> I would like to convert the following ruby/rake code to Clojure:
>
> Dir.chdir ENV["CLOJURE_HOME"] do
> system "git svn rebase"
> system "ant jar"
> end
>
> Since Java does not have the notion of a current directory, one way
On Sat, Jan 24, 2009 at 2:41 PM, Jeremy Bondeson wrote:
>
> I have uploaded a second diff [1] that has these simplifications.
Thanks for tracking this down. However, your patch cannot be accepted
until Rich has gotten your CA: http://clojure.org/contributing
Also, I believe he prefers patches
On Jan 25, 5:27 pm, Chouser wrote:
> On Sun, Jan 25, 2009 at 8:01 AM, Chouser wrote:
> > On Sun, Jan 25, 2009 at 7:06 AM, Anand Patil
> > wrote:
>
> >> I'd like to repeat my request for an example of definline usage; I
> >> feel I've tried everything.
>
> > I looked into this yesterday, and it
I figured out that I can run the command 'slime-repl' and get a valid
repl.
So the code I posted is all that is required to allow emacs to connect
to your running process. Amazingly short.
Chris
On Jan 25, 10:35 am, chris wrote:
> I have embedded clojure-swank in my program like so:
>
> (defn
Meikel Brandmeyer writes:
> Am 25.01.2009 um 17:11 schrieb Zak Wilson:
>
>> Clojure has that in the comment form: (comment (do (not (eval this
>
> No. That's not equivalent. comment leaves a nil behind, while #*
> would not.
>
> [:a (comment :b) :c] => [:a nil :c]
> [:a #* :b :c] => [:a :c]
people are paying a lot of attention to "pure" functional languages, which I
think mean ones that don't ever destroy data structures out from under
people pointing at them. Instead, people who need different views just get
their own different views -- possibly reusing common components.
This othe
I ran into a situation where I needed to replace an element in a
collection at a specific position, I ended up writing the following:
(defn replace-at [coll pos value]
"replaces an element in collection at pos with the value"
(let [parts (split-at pos coll)]
(concat (first parts) (cons va
On Jan 25, 5:34 pm, wubbie wrote:
> What's the typical usage of fn constantly ?
When you need a function that constantly returns the same result :)
That probably doesn't tell you any more than you know already, so I'll
give you a real world use. My rnd-utils library has a function
generating ra
oh, so anyway, i put it in that specific place because I wasn't sure if,
without it, l1 would just be some sort of smart, lazy list that only exists
when you start trying to get the values. I didn't think so, but, again, I'm
just trying to shotgun the problem.
On Sun, Jan 25, 2009 at 1:57 PM, e
thanks James,
I'll have a look.
-sun
On Jan 25, 2:00 pm, James Reeves wrote:
> On Jan 25, 5:34 pm, wubbie wrote:
>
> > What's the typical usage of fn constantly ?
>
> When you need a function that constantly returns the same result :)
>
> That probably doesn't tell you any more than you know
I think zip/down has a bug. It effectively does (when (children loc)
...), and since in Clojure empty list isn't false, it ends up adding
nodes in my tree.
Shouldn't it check for (when-not (empty? (children loc)) ...) ?
--J.
--~--~-~--~~~---~--~~
You received thi
On Jan 25, 2009, at 12:49 PM, Chouser wrote:
Also, I believe he prefers patches be attached to the email message
rather than uploaded to the files area.
Here's the latest I have seen from Rich on the topic of where to put
patches:
http://groups.google.com/group/clojure/msg/e4dfeed57620f5
Hi,
Am 25.01.2009 um 20:00 schrieb Dmitri:
I ran into a situation where I needed to replace an element in a
collection at a specific position, I ended up writing the following:
(defn replace-at [coll pos value]
"replaces an element in collection at pos with the value"
(let [parts (split-at p
On Jan 25, 12:27 pm, Chouser wrote:
> On Sun, Jan 25, 2009 at 8:01 AM, Chouser wrote:
> > On Sun, Jan 25, 2009 at 7:06 AM, Anand Patil
> > wrote:
>
> >> I'd like to repeat my request for an example of definline usage; I
> >> feel I've tried everything.
>
> > I looked into this yesterday, and
On Jan 25, 1:43 pm, Jan Rychter wrote:
> Meikel Brandmeyer writes:
> > Am 25.01.2009 um 17:11 schrieb Zak Wilson:
>
> >> Clojure has that in the comment form: (comment (do (not (eval this
>
> > No. That's not equivalent. comment leaves a nil behind, while #*
> > would not.
>
> > [:a (comme
On Jan 25, 2:29 pm, Meikel Brandmeyer wrote:
> Hi,
>
> Am 25.01.2009 um 20:00 schrieb Dmitri:
>
> > I ran into a situation where I needed to replace an element in a
> > collection at a specific position, I ended up writing the following:
>
> > (defn replace-at [coll pos value]
> > "replaces an
On Sun, Jan 25, 2009 at 1:43 PM, Rich Hickey wrote:
>
> On Jan 25, 1:43 pm, Jan Rychter wrote:
>> Meikel Brandmeyer writes:
>> > Am 25.01.2009 um 17:11 schrieb Zak Wilson:
>>
>> >> Clojure has that in the comment form: (comment (do (not (eval this
>>
>> > No. That's not equivalent. comment
In SVN 412 I have made the following changes to contrib:
* a test_contrib.clj file which does for contrib what test_clojure.clj
does for clojure
* a test_clojure task in build.xml
* a test_contrib task in build.xml
* a test task to aggregate all test tasks
This is *very* minimal, but I wanted
On Jan 25, 11:10 am, Konrad Hinsen wrote:
> For those who like me are playing with the stream-enabled branch of
> Clojure, there is a new module stream-utils on clojure.contrib:
>
>http://code.google.com/p/clojure-contrib/source/browse/trunk/src/
> clojure/contrib/stream-utils.clj
>
> O
Hi e,
Most of the time is taken up by printing, which is why you see the
same times. Here's an example that gives the results you would expect.
user> (def numbers (doall (take 50 (repeatedly #(rand-int
3000)
#'user/numbers
user> (defn predicate [x] (< x 1500))
#'user/predicate
user> (dot
On Sun, Jan 25, 2009 at 9:46 AM, Jan Rychter wrote:
>
> From what I understand, currently the only way is to get the root
> node and then recreate the entire zipper structure. This seems
> unnecessary.
I think what you're asking for sounds very reasonable. It's also
seems like it would have bee
Mark Volkmann writes:
> On Sun, Jan 25, 2009 at 1:43 PM, Rich Hickey wrote:
>> On Jan 25, 1:43 pm, Jan Rychter wrote:
>>> Meikel Brandmeyer writes:
>>> > Am 25.01.2009 um 17:11 schrieb Zak Wilson:
>>>
>>> >> Clojure has that in the comment form: (comment (do (not (eval this
>>>
>>> > No. T
Mark Volkmann writes:
> On Sun, Jan 25, 2009 at 1:43 PM, Rich Hickey wrote:
>> On Jan 25, 1:43 pm, Jan Rychter wrote:
>>> Meikel Brandmeyer writes:
>>> > Am 25.01.2009 um 17:11 schrieb Zak Wilson:
>>>
>>> >> Clojure has that in the comment form: (comment (do (not (eval this
>>>
>>> > No. T
Hi Rich, all,
Ever since the new implementation of watchers I've been itching to try
out Cells again. It worked great for agents. I ran into a snag,
though, when I tried to make cells out of refs. Here's an example.
I make two refs:
(def r1 (ref 1))
(def r2 (ref (+ 10 @r1)))
Add a wat
#- makes sense (CL didn't always make things the wrong way :-)
And indeed, #; *could* break a lot of already existing editors for a while
--
Laurent
2009/1/25 Jan Rychter
>
> Mark Volkmann writes:
> > On Sun, Jan 25, 2009 at 1:43 PM, Rich Hickey
> wrote:
> >> On Jan 25, 1:43 pm, Jan Rychter
Jan Rychter a écrit :
> I think zip/down has a bug. It effectively does (when (children loc)
> ...), and since in Clojure empty list isn't false, it ends up adding
> nodes in my tree.
>
> Shouldn't it check for (when-not (empty? (children loc)) ...) ?
>
The children fn (passed to the zipper cal
ok, those times make sense. The times are at least half the speed from the
single pass, and more so because no recursion.
So you have to do "dorun" to force the evaluation of each list? I was
wondering about this, too. If you had done doall on the answer, it wouldn't
have been a "deep execution"
Hi,
I saw dorun and doall in core.clj as follows:
That is, doall just calls dorun.
My question is, how come doall does force eval and dorun does not.
thanks in advance,
-sun
(defn dorun
([coll]
(when (and (seq coll) (or (first coll) true))
(recur (rest coll
([n coll]
(when (a
On Jan 25, 2009, at 5:24 PM, e wrote:
Do folks in the contrib group like this new implementation?
To make contributions to clojure-contrib, you'll need to have a
Contributor Agreement on file with Rich. Please see http://clojure.org/contributing
.
I think your implementation is an impro
Hi everybody, since I started using Clojure I've always felt that a
small function for turning a sequence of chars into a string was
missing. I'm currently using this one even though the name isn't quite
right, but I didn't found better:
(defn unseq [chars]
(new String (into-array (. Characte
On Jan 25, 2009, at 5:51 PM, wubbie wrote:
I saw dorun and doall in core.clj as follows:
That is, doall just calls dorun.
My question is, how come doall does force eval and dorun does not.
thanks in advance,
Both force evaluation. Immediately before either returns, there is a
fully realize
On Jan 25, 2009, at 6:21 PM, budu wrote:
So, is there a better way to accomplish this? Then, do someone have a
better name for it? And finally, would this be worth including into
Clojure or Clojure-contrib, with a better name?
The usual way to do this is with "(apply str ...)"
For example:
2009/1/26 Stephen C. Gilardi
>
> On Jan 25, 2009, at 5:51 PM, wubbie wrote:
>
> I saw dorun and doall in core.clj as follows:
> That is, doall just calls dorun.
> My question is, how come doall does force eval and dorun does not.
> thanks in advance,
>
>
> Both force evaluation. Immediately befo
Oh, I see the return value for doall.
When I look at dorun it is different than lots of other functions.
Unlinke lots of other functions that do conj, cons, etc. dorun just
extract each element of coll. Is each element get evaluated if it's a
code?
Thanks
-sun
(defn dorun
([coll]
(when
I have some tests ready for test_clojure. I asked Rich for SVN access
rights. There is gonna be more tests soon :-)
Frantisek
On Sun, Jan 25, 2009 at 8:55 PM, Stuart Halloway
wrote:
>
> In SVN 412 I have made the following changes to contrib:
>
> * a test_contrib.clj file which does for contrib
Following James's description, I would image constantly's
implementation to look something like the following.
(defn constantly [value] #(identity value))
If you haven't seen the # macro before, the form below is equivalent.
(defn constantly [value] (fn [] (identity value)))
Making use of Chri
On Jan 25, 2009, at 6:45 PM, Laurent PETIT wrote:
2009/1/26 Stephen C. Gilardi
Both force evaluation. Immediately before either returns, there is
a fully realized sequence in memory.
Are you sure ? I think the point of dorun is to prevent this case :
with dorun, the elements of the seq
then, back to my original question.
They (dorun do all) differe ONLY in return value.
Then how come one forces eval and the other not?
-sun
On Jan 25, 7:18 pm, "Stephen C. Gilardi" wrote:
> > On Jan 25, 2009, at 6:45 PM, Laurent PETIT wrote:
>
> >> 2009/1/26 Stephen C. Gilardi
>
> >> Both for
thanks for the insight!
On Jan 25, 7:06 pm, "rzeze...@gmail.com" wrote:
> Following James's description, I would image constantly's
> implementation to look something like the following.
>
> (defn constantly [value] #(identity value))
>
> If you haven't seen the # macro before, the form below is
On Jan 25, 2009, at 7:35 PM, wubbie wrote:
then, back to my original question.
They (dorun do all) differe ONLY in return value.
Then how come one forces eval and the other not?
Both force evaluation. Is there something that makes you think
otherwise?
In the case of dorun, the members of
On Jan 25, 2009, at 7:47 PM, Stephen C. Gilardi wrote:
In the case of dorun, the members of the sequence are evaluated and
then immediately thrown away.
"Immediately" overstates it... they are left unreferenced and get
thrown away when the Java garbage collector notices they are
unrefere
Thanks Steve for the clear explanation.
Now I get it...
But a question on "... are evaluated and then immediately thrown
away".
I believe the evaluation is done in (or (first coll) true)).
My question is that extracting out "first coll" is same as evaluating
"first coll"?
For example (first '( (+
On Jan 25, 2009, at 8:05 PM, wubbie wrote:
Wait... I just tried (first (list (+ 1 2) (+ 3 4))) and got 3!
So (list a b c) is different than '( a b c)? I thought they are
equivalent!
Right, as your experiment shows, the ' in '(a b c) quotes both the
list itself and all of its contents.
Usi
ok, I'll check that stuff out. Thanks.
It occurs to me this is being compared to something in ruby called
partition. I like that name. "partition-by" ... but maybe it was opted to
use the simpler name, which I can appreciate.
On that subject, I know "filter" is standard from other languages li
interesting to me that <> wasn't used for anything to add to the "literal
syntax". folks in another thread were using sequences for set theory. But
maybe there needs to be a set notation. If that makes sense, {} should be
sets, just like in math, <> should be vectors, just like in math, and []
c
Hi,
Am 26.01.2009 um 06:05 schrieb e:
interesting to me that <> wasn't used for anything to add to the
"literal syntax". folks in another thread were using sequences for
set theory. But maybe there needs to be a set notation. If that
makes sense, {} should be sets, just like in math, <>
OK, cartesian_product it is.
Two comments on your version. First, unlike mine (and the current
"combinations"), it takes a single argument, a seq of seqs (rather
than multiple seq arguments); which of these ways is preferred?
Second, I had the clauses of my for loop backwards, which was slowing
For simple inputs, the two approaches have similar performance. On
complex inputs, my tests show the iterative version tends to run about
twice as fast.
Try running on an extreme input like:
["ACDFG" "A" "B" "C" "D" "E" "F" "ABCD" "G" "H" "I" "ABEG" "J" "K"
"BCDE" "L" "ABCDG" "M" "EF" "NABC" "AB
76 matches
Mail list logo