If you are looking for a more idiomatic solution,
https://github.com/jpalmucci/clj-yield wraps a lazy sequence around a blocking
queue.
On May 30, 2013, at 11:58 AM, Artem Boytsov aboyt...@gmail.com wrote:
Hello, Colin,
I suspected I should turn to existing Java concurrency constructs.
Shameless plug: If you want to do this type of iteration efficiently, try my
library at https://github.com/jpalmucci/clj-iterate
user (iter {for x in '(1 2 3)}
{for y in '(a b c)}
(println x y))
1 a
2 b
3 c
nil
user
Expands into a fast loop/recur form. No intermediate data
In general, you can't convert recursion into loops. Recursion has
stack frames, loops don't.
I can't really tell what you are trying to do here because your
example just walks the interior nodes of the expression tree, doing
nothing. Can you clarify with a more complete example?
--
You received
http://github.com/jpalmucci/clj-return-from
On Jul 31, 12:41 pm, Sunil S Nandihalli sunil.nandiha...@gmail.com
wrote:
Hi Ken,
thank you for your response. Do you think you can give me a quick example
of how to extend an Exception to be able to extract the value from the
exception when it is
An implementation of common lisp's return-from for clojure. Just a
small little hack, but it really bugged me when I needed it and it
wasn't there.
https://github.com/jpalmucci/clj-return-from
From the README:
# clj-return-from
An implementation of common lisp's return-from for clojure
##
I get the same thing with just plain leiningen. It's not cake.
On Apr 25, 2011, at 5:22 AM, Sam Aaron wrote:
Hi George,
On 25 Apr 2011, at 00:14, George Jahad wrote:
Technomancy has been kind enough to merge it into the main swank-
clojure repo, so it will a part of swank-clojure releases
My problem was that I was including incanter, which depends on swank-clojure
1.3.0-snapshot, which was conflicting with 1.4.
I deleted the swank-clojure 1.3 jar from 'lib' and it worked.
On Apr 25, 2011, at 10:41 AM, George Jahad wrote:
strange. haven't seen that one before.
can you and
I'd like to propose different implementation of defnk, attached below.
Defnk2 translates keyword arguments to positional arguments at compile
time, and is therefore about 36x faster on my machine.
(defn expand-keyword-call [name pos kw-defaults args]
(if ( (count args) (count pos))
(throw
I've worked around this sort of thing in the past by wrapping the
initialization in a closure. My macros:
(defmacro once-fn Define a function that should only be called once.
Releases local storage earlier
[args body]
`(^{:once true} fn* ~args ~...@body))
(defmacro top-level-run work around
I'd use my clj-iterate library at http://github.com/jpalmucci/clj-iterate.
user (iter {for x in [1 2 3]}
{for y in [11 22 33]}
(println x y))
1 11
2 22
3 33
nil
Won't collect the sequence if you don't ask for it, and its eager (and
fast).
It's also available at clojars.
Sorry, I posted this question and it turned up under the 1.3 Alpha 1
thread. Apparently you cannot reply to an email from the group, edit
the header, and start a new discussion. Here it is again:
I have a very simple test case in clojure 1.2:
(def *1* (count (range 0 1)))
I have a
I have a very simple test case in clojure 1.2:
(def * 1* (count (range 0 1)))
I have a loop running in another thread that periodically causes a full gc and
then prints the amount of used memory every 2 seconds. Evaluating the above
form, I get:
Used memory: 0.079951296 G
Used
Just came across this problem on RC3.
Here is a fix:
diff --git a/src/jvm/clojure/lang/RT.java b/src/jvm/clojure/lang/RT.java
index 9aea629..5e67449 100644
--- a/src/jvm/clojure/lang/RT.java
+++ b/src/jvm/clojure/lang/RT.java
@@ -678,7 +678,11 @@ static public Object contains(Object coll, Object
scanner)
(lazy-seq (get-next)]
(.useDelimiter scanner regex)
(get-next)))
On Aug 17, 2010, at 2:29 PM, Jeff Palmucci wrote:
I'm assuming your problem is with memory, and not multithreaded reading.
Given that:
I also work with files much too big to fit
.
On Aug 5, 5:59 pm, David Andrews dammi...@gmail.com wrote:
On Aug 3, 5:28 pm, Jeff Palmucci jpalmu...@gmail.com wrote:
See my library athttp://github.com/jpalmucci/clj-yield, which makes
this trivial.
This looks really nice, Jeff. Thanks. Exactly what I was looking
for.
I notice
with a take
function if you only cared about the first few lines. As far as I
know, this would still close the resources after whether you realize
the whole sequence or only take part of it. Can someone who knows a
bit better confirm?
On Aug 3, 5:28 pm, Jeff Palmucci jpalmu...@gmail.com wrote:
See
See my library at http://github.com/jpalmucci/clj-yield, which makes
this trivial.
For example, here is a function I use to read a sequence of java
serialized objects from a stream:
(defn read-objects [path]
(with-yielding [out 1000]
(with-open [stream (java.io.ObjectInputStream.
17 matches
Mail list logo