On Jan 24, 2009, at 6:01 PM, Stephen C. Gilardi wrote:
> On Jan 24, 2009, at 8:11 PM, Jason Wolfe wrote:
>> Finally, I don't know how to make a patch, and found nothing in a
>> quick search of the wiki/newsgroup/website. I heard "Git" floating
>> around somewhere earlier; am I to check out the S
> 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 amount. I don't
> know the JVM very well at
I'm trying to debug a problem in one of my programs in which PermGen
usage grows with and during each run (cumulatively within the same
REPL session) until I eventually run out & get the out of memory JVM
exception. So I wrote the following utility just to help me track
usage while I hack:
(defn
Steve, thank you very much for your detailed and clear explanation.
Yes, I see many refs when I google-search for it and clues in them for
the answer. I should have done it before asking. Lazy-seqs bite lazy
bones like me.
Thanks, again.
--Kei
On Jan 24, 10:34 pm, "Stephen C. Gilardi" wrote:
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. While let-eval is cool, using it
It's the laziness; because the value of the call to map is never
consumed, it is never produced either, so the throw never happens.
On Jan 25, 1:05 am, Kei Suzuki wrote:
> Form3 makes me puzzled. Form1 and Form2 throw exception as expected.
> Why doesn't Form3?
>
> Form1: (do ((fn [] (throw (Exc
The map function returns a lazy sequence. Unless something forces the
members of the sequence to be evaluated, they won't be.
In Form1, you explicitly call an anonymous function that throws.
In Form2, the sequence returned by map is the last value in the "do"
form, so it is the value of the
Form3 makes me puzzled. Form1 and Form2 throw exception as expected.
Why doesn't Form3?
Form1: (do ((fn [] (throw (Exception. "oops" :ok)
Form2: (do ((fn [] (map #(when % (throw (Exception. "oops")))
[true]
Form3: (do ((fn [] (map #(when % (throw (Exception. "oops")))
[true]))) :ok)
Than
I'm trying to learn Swing, so I'm writing the most robust Celsius
converter app that I can. I've separated the conversion work into a
separate SwingWorker thread, so this requires Java 6. Does anyone have
any suggestions?
(ns org.sample.play-with-swing.multithreaded-celsius-converter
(:impo
On Jan 24, 2009, at 10:14 PM, wubbie wrote:
How do you define side-effects?
There's a good description here:
http://en.wikipedia.org/wiki/Side_effect_(computer_science)
--Steve
smime.p7s
Description: S/MIME cryptographic signature
How do you define side-effects?
-sun
On Jan 24, 5:26 am, Christophe Grand wrote:
> Tzach a écrit :
>
> > The text on the panel do update.
> > When I try to do the same for all the elements:
> > (for [t (components r)]
> > (.setText t (str 6)))
>
> > Nothing happened.
> > What am I missing
On Jan 24, 2009, at 8:11 PM, Jason Wolfe wrote:
Finally, I don't know how to make a patch, and found nothing in a
quick search of the wiki/newsgroup/website. I heard "Git" floating
around somewhere earlier; am I to check out the SVN with git-svn and
make a patch that way?
To prepare a patch,
>
> I recommend people avoid these predicates as much as possible. But
> what they do is clearly defined. I don't intend to add seqable?, and
> sequence?, at least as we've discussed here.
>
>
This sounds right to me, too, but I wonder if my reasons are the same. This
isn't Eiffel. There's no sec
> I'm all for optimizing for size here, however, the fact that these
> functions happen to work when the second argument is not a set is an
> implementation artifact and not a promise of the interface, so I'm not
> in favor of the set? testing or any other accommodation of that.
OK, from that I t
I've worked on the library today, and imported it into a GitHub
project: http://github.com/gnuvince/clojure-greatest-least/tree/master
I've added a variation of all four functions that returns all the
greatest/least elements as well as a small test suite.
Could this be an interesting addition to
On Jan 24, 5:00 pm, Mark Engelberg wrote:
> On Sat, Jan 24, 2009 at 9:06 AM, Rich Hickey wrote:
> > You gotten tied up, here and elsewhere, conflating sequence with
> > container, and almost all of your problems stem from wanting to say
> > sequence and have it mean container. If you want to
Word "streams" invokes association to data-flow languages. For a
while, I was following Project V:
Simple Example of the Difference Between Imperative, Functional and
Data Flow.
http://my.opera.com/Vorlath/blog/2008/01/06/simple-example-of-the-difference-between-imperative-functional-and-data-flo
Thanks Joshua,
This is fixed in the next beta.
Stuart
> A related point about the validator function (for Refs), possible
> the result of the same change in the Clojure codebase
> On page 133 of Beta 5.0,
>
> (def messages (ref () :validator validate-message-list)
>
> The code samples,
On Sat, Jan 24, 2009 at 9:06 AM, Rich Hickey wrote:
> This is already wrong, right? Don't you mean (set s)? You haven't said
> what (powerset [1 2 3 2 1]) is going to be. subsequences != subsets.
Despite the name "powerset" being inspired by sets, when I posed the
puzzle of generalizing the beha
A related point about the validator function (for Refs), possible the result
of the same change in the Clojure codebaseOn page 133 of Beta 5.0,
(def messages (ref () :validator validate-message-list)
The code samples, using, the bundled clojure, do work. However, right above
the code on p.
After thinking about it some more (bigdec (/ 1 3)) should be
equivalent to (/ 1M 3) which actually throws the ArithmeticException,
so this would do away with the need for decimalValueSafe, and bigdec
should simply perform a division on a ratio.
I have uploaded a second diff [1] that has these sim
The current implementation of conversion of clojure.lang.Ratio class
to BigDecimal (via bigdec) or to a fixed precision floating point
value is not what one would expect. For example:
user> (double (/ (expt 2 1024) 3))
Infinity
when in fact it should return: 5.992310449541053E307
and
user=> (b
On 24 Jan., 16:50, wubbie wrote:
> Hi,
>
> I wonder why self-call(filter) is used in one place and
> recur is used in the other.
>
> (defn filter
> "Returns a lazy seq of the items in coll for which
> (pred item) returns true. pred must be free of side-effects."
> [pred coll]
> (when (s
On Jan 24, 2009, at 11:17 AM, wubbie wrote:
I understand vaguely.
My understanding is that recur is related to tail-call-optimization.
Where can I get more detailed info on recur?
A search on Google for:
clojure recur
brings up some good references.
--Steve
smime.p7s
Description
when is like do with only the 'then' branch wrapped in a do:
(if foo
(do
(println "hi")
42)))
is the same as
(when foo
(println "hi")
42)
And like if without an else branch, when returns nil if its predicate
yields false.
On Jan 24, 9:33 am, wubbie wrote:
> Here is code from co
from my background, you can only go by what people promise. The interface
promises it will work with maps. using anything else is undefined
behavior. So I am wrong to assume anything about sort, also, under the same
argument.
it like this : http://www.fallacyfiles.org/afthecon.html
you can onl
On Jan 24, 7:31 am, e wrote:
> Then again, I already chimed in. a list isn't a set. You said so in the
> introduction. Maybe set's need there own print representation, like <>
> . uh oh, starting to look like C++
Like this?:
user=> (hash-set 1 2 3)
#{1 2 3}
> On Sat, Jan 24, 2009 at 3
I understand that merge uses conj, but my point remains. I, and I
would imagine at least a few others in the programming world, view an
API's documentation as it's contract with the rest of the world. In
general it tells me what the function expects from me, and what I
should expect from the fun
On Jan 24, 3:43 am, Mark Engelberg wrote:
> Now that everyone's had a day to mull this puzzle over, here are my thoughts.
>
> One way to think about this, is to think about what the statement of
> purpose / contract of a generalized powerset function would be. In
> general, most functions on s
I understand vaguely.
My understanding is that recur is related to tail-call-optimization.
Where can I get more detailed info on recur?
thanks
-sun
On Jan 24, 11:00 am, Meikel Brandmeyer wrote:
> Hi,
>
> Am 24.01.2009 um 16:50 schrieb wubbie:
>
> > I wonder why self-call(filter) is used in one
> Now you
> wont be able to run this unless you modify Agent.java, search for
> soloExectuor, make it public, and recompile Clojure.
is this a code change people want to make?
>
>
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to
I use the philosophy, I've got this nice hammer with a nail remover on the
back. It's a natural fit that sometimes you want to pull nails out in
addition to hammering nails in. For those two jobs, I don't need to be
walking around with a special nail-remover-only tool. and if has fewer
character
Hi,
Am 24.01.2009 um 16:50 schrieb wubbie:
I wonder why self-call(filter) is used in one place and
recur is used in the other.
The filter call happens inside the lazy-cons. That means
that the call to filter does not happen immediately, but
later on when you call rest on the lazy-cons.
The r
In core.clj, merge is essentially defined using conj.
user=> (merge '(1) 2)
(2 1)
user=> (merge [1] 2)
[1 2]
user=> (merge #{1} 2)
#{1 2}
user=> (conj '(1) 2)
(2 1)
user=> (conj [1] 2)
[1 2]
user=> (conj #{1} 2)
#{1 2}
user=> (conj {:name "ryan"} {:age 25})
{:age 25, :name "ryan"}
-sun
On Jan
On 24.01.2009, at 16:34, Rich Hickey wrote:
> So, thread-local vars are not what you want.
That's what I figured out in the meantime, and I settled for an array:
(defn int-stream []
(let [n (into-array [0])]
(stream
(fn [_]
(let [current (aget n 0)]
(aset n 0 (i
merge confused me, too. I was surprised to see in the docs that its input
needn't be sorted (or have anything to do with lists) . . . .or maybe it
merges unsorted things however, but where's the discussion of whether the
result of merging two sorted list is a sorted list? Well, it's avoided
beca
Hi,
I wonder why self-call(filter) is used in one place and
recur is used in the other.
(defn filter
"Returns a lazy seq of the items in coll for which
(pred item) returns true. pred must be free of side-effects."
[pred coll]
(when (seq coll)
(if (pred (first coll))
(la
Hi,
Am 24.01.2009 um 15:33 schrieb wubbie:
The question is when to use when or if.
'When' does have only one branch, while if has two.
(when test the-branch)
(if test then else)
I use 'when' for side-effects or in case there is only
one interesting branch.
(defn do-something
[x]
(when
I know when is a macro and if is a special form.
"when" might be more efficient (short-circuit test).
Why "when" is used in take and if is used in drop.
thanks
-sun
On Jan 24, 10:35 am, e wrote:
> thanks for putting these side by side so I could get an idea what when
> does. Up until now, wh
thanks for putting these side by side so I could get an idea what when
does. Up until now, when I see "when", my eyes have glazed over. Thus the
only reason I need when is to read other people's code. Good question. Is
there a reason to have when?
On Sat, Jan 24, 2009 at 9:33 AM, wubbie wrote
On Jan 24, 6:29 am, Konrad Hinsen wrote:
> I am trying to generate a var for use in a generator for a stream. As
> a simple example, let's try to create a stream of integers. My first
> attempt at the generator was:
>
> (with-local-vars [n 0]
>(defn integers [_]
> (let [current (var-ge
this may be a silly argument, but:
(list? '()) returns true
(list? nil) returns false
(list? 'nil) returns false. I don't even know what it means.
therefore nil isn't a list.
Then again, I already chimed in. a list isn't a set. You said so in the
introduction. Maybe set's need there own pr
On Jan 23, 6:05 pm, Christian Vest Hansen
wrote:
> On Fri, Jan 23, 2009 at 11:06 PM, Rich Hickey wrote:
>
> > On Jan 23, 1:47 pm, Christian Vest Hansen
> > wrote:
> >> I type this expression in the REPL (trunk 1228):
>
> >> user=> (let [s (.keySet {:a 1})] [(set? s) (ifn? s)])
> >> [false fal
Here is code from core.clj.
The question is when to use when or if.
(defn take
"Returns a lazy seq of the first n items in coll, or all items if
there are fewer than n."
[n coll]
(when (and (pos? n) (seq coll))
(lazy-cons (first coll) (when (> n 1) (take (dec n) (rest
coll)
Rich Hickey a écrit :
> That's an arbitrary limitation - patch welcome.
>
> Rich
>
Issue #53:
http://code.google.com/p/clojure/issues/detail?id=53
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
T
On Jan 23, 10:48 am, Zak Wilson wrote:
> If a speed boost is what you're going for, you can probably get one
> from type coercion and (if you're not worried about overflow)
> unchecked-math. As an example:
>
> (defn step [x0, y0, xn, yn]
>(let [dx0 (double x0)
> dy0 (double y0)
>
On Jan 23, 2009, at 11:37 AM, Jason Riedy wrote:
>
> And Rich Hickey writes:
>> You can use the logo on the wikipedia article on Clojure, but only if
>> you spell my name correctly :)
>
> May I use the logo for the identi.ca group? ( http://identi.ca/group/clj
> )
>
>
Sure.
Rich
--~--~---
On Jan 23, 5:42 pm, Jason Wolfe wrote:
> > I appreciate your desire to contribute, but Clojure is not just about
> > your needs. You have flooded the group with every idea you have, some
> > are bugs (important), some are good ideas, some not, but there are
> > simply too many to address at the
On Jan 23, 2009, at 1:35 PM, Christophe Grand wrote:
>
> Christophe Grand a écrit :
>> tree-seq assumes the root is a branch:
>> user=> (tree-seq (constantly false) seq [1 2 3])
>> ([1 2 3] 1 2 3) ; I expected ([1 2 3])
>>
>> Is this a bug?
>>
> I know it's documented but I don't understand why.
I am trying to generate a var for use in a generator for a stream. As
a simple example, let's try to create a stream of integers. My first
attempt at the generator was:
(with-local-vars [n 0]
(defn integers [_]
(let [current (var-get n)]
(var-set n (inc current))
current
On 24.01.2009, at 09:43, Mark Engelberg wrote:
> Anyone want to try to convince me otherwise? If you think my logic is
> flawed, I'd love to hear your take on this problem.
It's not a question of logic but of priorities. As you explained very
well, there is no obviously ideal solution. So wha
Tzach a écrit :
> The text on the panel do update.
> When I try to do the same for all the elements:
> (for [t (components r)]
> (.setText t (str 6)))
>
> Nothing happened.
> What am I missing here?
'for should not used for side effects because it is lazy. (To force it
to perform the comp
I'm working a Sudoku GUI interface using swing, and I notice something
strange.
I have a JPanel r, with 9 JTextField added to it.
I created a small function to return the text filed of a panel:
(defn components [container]
(for [i (range (.getComponentCount container))]
(.getComponent conta
On Fri, Jan 23, 2009 at 11:43 PM, wrote:
> I think the usual mathematical name is be cartesian-product (or maybe
> cross-product), although selections is OK with me too.
Yes, now that you've reminded me, I agree that cartesian-product is
the usual mathematical name, and that would probably be m
samppi a écrit :
> sync and dosync's documentation seems to be virtually the same, except
> for the unimplemented flags-ignored-for-now parameter of sync. What is
> the difference in their functions?
>
Right now there's none:
(defmacro dosync
"..."
[& exprs]
`(sync nil ~...@exprs)
Now that everyone's had a day to mull this puzzle over, here are my thoughts.
One way to think about this, is to think about what the statement of
purpose / contract of a generalized powerset function would be. In
general, most functions on seq-able objects return sequences. For
example, (rest
You must eval the whole fn form:
(defn compile-rule [body]
(eval (list `fn '[a b] body)))
user=> (let [f (compile-rule '(+ a b))]
(f 18 56))
74
Zak Wilson a écrit :
> So as it turns out, I was mistaken about it working. I had something
> that ran, but the results were nonsense. What I'm tr
Correction: it's
(let [x '(+ (* 1024 device-id) rave-id))
rfn (rulefn x)]
...)
that fails with "Can't eval locals".
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, s
So as it turns out, I was mistaken about it working. I had something
that ran, but the results were nonsense. What I'm trying now looks
like this:
(defmacro rulefn [r]
(let [er (eval r)]
`(fn [devid# raveid#]
(binding [device-id devid#
rave-id raveid#]
~er
59 matches
Mail list logo