On Jun 12, 10:31 am, Chouser wrote:
> On Thu, Jun 11, 2009 at 8:48 PM, Stephen C. Gilardi wrote:
>
> > > Do you think there will be any performance hits.
>
> > I haven't run any tools on it. In looking around the reflection-related code
> > in clojure.lang, it looks to me like the performance o
Hello James,
Thank you for more examples.
> > (count (take-while belowCount (filter identity (map isInteresting
> > pixels
> This particular piece of code doesn't look like it would work, unless
> I've misunderstood what Vlad is asking. I think you'd want something
> more like:
If I unders
Hi Vlad,
I just realized that you don't need the take-while.
(take num coll) will directly retrieve up-to num elements out of coll.
Cheers
-Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
T
On Jun 12, 9:44 pm, James Reeves wrote:
> (defn count-more-than? [n xs]
> (or (zero? n)
> (if (seq xs)
> (recur (dec n) (rest xs)
>
> (defn interesting? [pixels c]
> (count-more-than? c (filter in-interval? pixels)))
Nice, but
user=> (count-more-than? 0 ())
tru
On Jun 13, 3:03 pm, Emeka wrote:
> kedu Wrexsoul
>
> user=> (count-more-than? 0 ())
> true
>
> (defn count-more-than? [n xs]
> (if (not (seq xs))
> (or (zero? n)
> (recur (dec n) (rest xs)
>
> I'm afraid your code didn't return true for me.
That's the idea. This version doesn't hav
kedu Wrexsoul
user=> (count-more-than? 0 ())
true
(defn count-more-than? [n xs]
(if (not (seq xs))
(or (zero? n)
(recur (dec n) (rest xs)
I'm afraid your code didn't return true for me. Just look at your code, (seq
'()) will always give nil, so your code will return nil and not tru
On Thu, Jun 11, 2009 at 2:54 AM, Seth wrote:
>
> So the 12th International Conference on Functional Programming is
> coming up soon. A few months before the event a programming contest is
> held, typically with very ambitious requirements in a short period of
> time (2-3 days). The 2009 contest wi
Hi,
Am 13.06.2009 um 02:45 schrieb Wrexsoul:
I think this exists already somewhere in clojure.contrib.java-utils
or
so.
Don't have that third-party library.
Maybe clojure.contrib.duck-streams?
Don't have that third-party library.
Then you should check it out, no?
Let's see.
http://
On Jun 13, 6:38 am, Wrexsoul wrote:
> Here's a bit more, public domain as usual:
>
> (defn get-ultimate-cause [exception]
> (loop [e exception]
> (let [e2 (. e getCause)]
> (if-not e2
> e
> (recur e2)
I think something like this is in clojure-contrib as well. It'
Hi Laurent,
I like how you distilled the problem down to a reduce with an early-
exit.
I'm interested in what you said about my suggestion:
"using map then filter then take then count, which will
result in creating, for at least num pixels, at worst the full number
of pixels, 2 conses, and 3 tim
On Jun 13, 9:17 pm, Laurent PETIT wrote:
> This thread is interesting because we have a solution that is
> suggested : using map then filter then take then count, which will
> result in creating, for at least num pixels, at worst the full number
> of pixels, 2 conses, and 3 times walking the arra
2009/6/13 CuppoJava :
>
> Hi Laurent,
> I like how you distilled the problem down to a reduce with an early-
> exit.
>
> I'm interested in what you said about my suggestion:
>
> "using map then filter then take then count, which will
> result in creating, for at least num pixels, at worst the full
On Jun 13, 7:02 pm, Wrexsoul wrote:
> Nice, but
>
> user=> (count-more-than? 0 ())
> true
>
> (defn count-more-than? [n xs]
> (if (seq xs)
> (or (zero? n)
> (recur (dec n) (rest xs)
True enough. My code didn't take into account that edge case.
- James
--~--~-~--~~---
On Jun 13, 9:39 pm, Laurent PETIT wrote:
> Well, the array is iterated once by map, the new seq created by map is
> iterated once by filter, and the new seq created by filter is iterated
> once by count, so right, I should have written : 3 walks of seqs of
> the size of the array.
The filter and
Hi,
This thread is interesting because we have a solution that is
suggested : using map then filter then take then count, which will
result in creating, for at least num pixels, at worst the full number
of pixels, 2 conses, and 3 times walking the array.
What's more interesting to me is that the
On Thu, Jun 11, 2009 at 7:12 PM, peg wrote:
>
> Hi clojurians,
>
> I was happily clojure-coding whent I tried to catch a exception in a
> thrown deeply in a function.
>
> After looking for the fact that the IllegalArgumentException wasn't
> catch, I added a catch RuntimeException to my catch list
2009/6/13 James Reeves :
>
> On Jun 13, 9:39 pm, Laurent PETIT wrote:
>> Well, the array is iterated once by map, the new seq created by map is
>> iterated once by filter, and the new seq created by filter is iterated
>> once by count, so right, I should have written : 3 walks of seqs of
>> the s
Now I'm working on some Swing code and came up with these, which are
obviously going to be useful:
(defmacro do-on-edt [& body]
`(SwingUtilities/invokeLater #(do ~...@body)))
(defmacro get-on-edt [& body]
`(let [ret# (atom nil)]
(SwingUtilities/invokeLater #(reset! ret# [(do ~...@body)]
Thank you so much for giving us your light, master of the dotted pair
notation ;-)
2009/6/13 Wrexsoul :
>
> Now I'm working on some Swing code and came up with these, which are
> obviously going to be useful:
>
> (defmacro do-on-edt [& body]
> `(SwingUtilities/invokeLater #(do ~...@body)))
>
> (
On Jun 13, 4:11 pm, Jarkko Oranen wrote:
> Also, try using (find-doc "foo") and (doc foo) in a repl for
> documentation searches. For this function, you might want to check out
> if-let.
Find-doc seems to give about the same results as searching through the
API page, only also cluttering up the
Hi,
Am 13.06.2009 um 23:02 schrieb Wrexsoul:
Now I'm working on some Swing code and came up with these, which are
obviously going to be useful:
And which are partly in clojure.contrib.swing-utils :)
(defmacro do-on-edt [& body]
`(SwingUtilities/invokeLater #(do ~...@body)))
(defmacro get-
On Sat, Jun 13, 2009 at 2:02 PM, Wrexsoul wrote:
>
> Now I'm working on some Swing code and came up with these, which are
> obviously going to be useful:
>
> (defmacro do-on-edt [& body]
> `(SwingUtilities/invokeLater #(do ~...@body)))
>
> (defmacro get-on-edt [& body]
> `(let [ret# (atom nil)]
Hi,
Am 13.06.2009 um 23:29 schrieb Meikel Brandmeyer:
(defmacro get-on-edt
[& body]
`(get-on-edt* (fn [] ~body)))
Of course ~...@body instead of ~body...
Sincerely
Meikel
smime.p7s
Description: S/MIME cryptographic signature
On Sat, Jun 13, 2009 at 2:55 PM, Meikel Brandmeyer wrote:
> Hi,
>
> Am 13.06.2009 um 23:29 schrieb Meikel Brandmeyer:
>
>> (defmacro get-on-edt
>> [& body]
>> `(get-on-edt* (fn [] ~body)))
>
> Of course ~...@body instead of ~body...
>
> Sincerely
> Meikel
>
>
I know you (Meikel) already fixed i
On Sat, Jun 13, 2009 at 10:11 PM, Jarkko Oranen wrote:
[...]
> I think something like this is in clojure-contrib as well. It's a semi-
> official add-on library for Clojure (You need a CA to contribute), so
> you should take a look at it :)
Wrexsoul: Since you don't seem to have stumbled across
On Sat, Jun 13, 2009 at 11:27 PM, Wrexsoul wrote:
>
> On Jun 13, 4:11 pm, Jarkko Oranen wrote:
[...]
>> I also personally dislike functions that take a boolean parameter; if
>> you must, at least make it optional, with default to false
>
> The -raw ending is one I use on functions that tend to ha
Isn't this a case of wrapping a Java API needlessly?
What's so bad about: (SwingUtilities/invokeLater my-func) ?
-- Aaron
On Sat, Jun 13, 2009 at 5:59 PM, Kevin Downey wrote:
>
> On Sat, Jun 13, 2009 at 2:55 PM, Meikel Brandmeyer wrote:
>> Hi,
>>
>> Am 13.06.2009 um 23:29 schrieb Meikel Brandm
it depends how often you are pushing stuff onto the EDT. I have a
similar macro called EDT so I can do stuff like (EDT (.setText foo
"bar")) alternatively I would need to type (SwingUtilities/invokeLater
#(.setText foo "bar")) or even (SwingUtilities/invokeLater (fn []
(.setText foo "bar")))
On S
On Jun 13, 9:57 pm, Laurent PETIT wrote:
> > The filter and map functions produce lazy seqs, so the sequence is
> > only walked once.
>
> Well, isn't walking 3 different sequences 1 time almost equivalent (in
> terms of computer work) to walking 3 times one sequence ?
Well, I guess there's the o
On Jun 13, 4:18 am, Wrexsoul wrote:
> Between files-and-dirs and file-lines-seq I think I have saved as many
> lines of code as are in the macro+helper fns, so those are at break-
> even.
I'm not completely sure what benefit super-lazy-seq is meant to have.
Could you perhaps give an example writ
On Jun 13, 9:24 pm, James Reeves wrote:
> On Jun 13, 4:18 am, Wrexsoul wrote:
>
> > Between files-and-dirs and file-lines-seq I think I have saved as many
> > lines of code as are in the macro+helper fns, so those are at break-
> > even.
>
> I'm not completely sure what benefit super-lazy-seq is
On Jun 13, 6:20 pm, Michael Wood wrote:
> On Sat, Jun 13, 2009 at 10:11 PM, Jarkko Oranen wrote:
>
> [...]
>
> > I think something like this is in clojure-contrib as well. It's a semi-
> > official add-on library for Clojure (You need a CA to contribute), so
> > you should take a look at it :)
>
I'm writing some simple code, and I believe I'm running into trouble
getting a primitive char.
user=> (def s (new StringBuilder "aaa"))
#'user/s
; Java method signature is setCharAt(int index, char ch)
user=> (. s setCharAt (int 0) (char \a))
java.lang.IllegalArgumentException: No matching meth
user=> (def s (StringBuilder. "aaa"))
#'user/s
user=> (. s setCharAt 0 \b)
nil
user=> s
#
user=> (. s setCharAt (int 0) (char \b))
nil
user=> (. s setCharAt (int 0) (char \e))
nil
user=> s
#
user=>
works for me
On Sat, Jun 13, 2009 at 7:28 PM, tmountain wrote:
>
> I'm writing some simple code,
On Jun 13, 2009, at 7:37 PM, Kevin Downey wrote:
works for me
It's working for me in Java 6, but not Java 5. It looks like something
changed there. In Java 5, I'm getting:
user=> (.setCharAt s 0 \c)
java.lang.IllegalArgumentException: Can't call public method of non-
public class: public
On Jun 14, 3:21 am, Wrexsoul wrote:
> It lets you write the generator in a style similar to loop/recur, and
> generally in half the code. And, it demonstrates the kinds of things
> you can do with macros.
Ahh, I see. That could be useful under some circumstances. However,
most Clojure functions
On Jun 13, 11:07 pm, James Reeves wrote:
> For instance, lets say I want to return a lazy list of all the lines
> in all the files in a directory tree:
>
> (use '(clojure.contrib java-utils
> duck-streams))
When clojure.contrib releases version 1.0, that might be an op
On Jun 13, 10:46 pm, "Stephen C. Gilardi" wrote:
> On Jun 13, 2009, at 7:37 PM, Kevin Downey wrote:
>
> > works for me
>
> It's working for me in Java 6, but not Java 5. It looks like something
> changed there.
Autoboxing.
What I miss is foo-array for foo not in #{int long float double},
part
I actually really do like the reduce with early exit abstraction.
Because ultimately, that's what the question is. It's a reduce with
optimization.
However, I feel that Laurence's reduce is a little too specific. The
early exit condition is very likely to *not* depend on the reduce
accumulator, b
39 matches
Mail list logo