On Jun 12, 10:31 am, Chouser chou...@gmail.com wrote:
On Thu, Jun 11, 2009 at 8:48 PM, Stephen C. Gilardisquee...@mac.com 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
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 understood
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.
To
On Jun 12, 9:44 pm, James Reeves weavejes...@googlemail.com 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=
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
On Thu, Jun 11, 2009 at 2:54 AM, Sethseth.schroe...@gmail.com 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).
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.
On Jun 13, 6:38 am, Wrexsoul d2387...@bsnow.net 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
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
On Jun 13, 9:17 pm, Laurent PETIT laurent.pe...@gmail.com 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
2009/6/13 CuppoJava patrickli_2...@hotmail.com:
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,
On Jun 13, 7:02 pm, Wrexsoul d2387...@bsnow.net 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 laurent.pe...@gmail.com 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
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, pegphilippe.gi...@gmail.com 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
2009/6/13 James Reeves weavejes...@googlemail.com:
On Jun 13, 9:39 pm, Laurent PETIT laurent.pe...@gmail.com 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
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
Thank you so much for giving us your light, master of the dotted pair
notation ;-)
2009/6/13 Wrexsoul d2387...@bsnow.net:
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
On Jun 13, 4:11 pm, Jarkko Oranen chous...@gmail.com 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
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
On Sat, Jun 13, 2009 at 2:02 PM, Wrexsould2387...@bsnow.net 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#
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 Brandmeyerm...@kotka.de 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 it,
On Sat, Jun 13, 2009 at 10:11 PM, Jarkko Oranenchous...@gmail.com 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
On Sat, Jun 13, 2009 at 11:27 PM, Wrexsould2387...@bsnow.net wrote:
On Jun 13, 4:11 pm, Jarkko Oranen chous...@gmail.com 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
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 Downeyredc...@gmail.com wrote:
On Sat, Jun 13, 2009 at 2:55 PM, Meikel Brandmeyerm...@kotka.de wrote:
Hi,
Am 13.06.2009 um
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 Sat,
On Jun 13, 9:57 pm, Laurent PETIT laurent.pe...@gmail.com 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
On Jun 13, 4:18 am, Wrexsoul d2387...@bsnow.net 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
On Jun 13, 9:24 pm, James Reeves weavejes...@googlemail.com wrote:
On Jun 13, 4:18 am, Wrexsoul d2387...@bsnow.net 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
On Jun 13, 6:20 pm, Michael Wood esiot...@gmail.com wrote:
On Sat, Jun 13, 2009 at 10:11 PM, Jarkko Oranenchous...@gmail.com 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
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 method
user= (def s (StringBuilder. aaa))
#'user/s
user= (. s setCharAt 0 \b)
nil
user= s
#StringBuilder baa
user= (. s setCharAt (int 0) (char \b))
nil
user= (. s setCharAt (int 0) (char \e))
nil
user= s
#StringBuilder eaa
user=
works for me
On Sat, Jun 13, 2009 at 7:28 PM,
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 d2387...@bsnow.net 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
On Jun 13, 11:07 pm, James Reeves weavejes...@googlemail.com 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
On Jun 13, 10:46 pm, Stephen C. Gilardi squee...@mac.com 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
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,
38 matches
Mail list logo