Re: A blocking lazy sequence populated by multiple worker threads

2013-06-12 Thread Jeff Palmucci
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.

Re: How to loop over several sequences in parallel for side-effects?

2012-01-23 Thread Jeff Palmucci
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

Re: How to convert general recursion to loop .. recur syntax

2011-09-14 Thread Jeff Palmucci
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

Re: timed termination of iterative algorithm

2011-07-31 Thread Jeff Palmucci
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

ANN: clj-return-from

2011-06-03 Thread Jeff Palmucci
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 ##

Re: swank-cdt: Using Slime with the Clojure Debugging Toolkit

2011-04-25 Thread Jeff Palmucci
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

Re: swank-cdt: Using Slime with the Clojure Debugging Toolkit

2011-04-25 Thread Jeff Palmucci
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

Proposal for new implementation of defnk

2011-01-24 Thread Jeff Palmucci
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

Re: Out of memory

2010-12-22 Thread Jeff Palmucci
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

Re: Iterating through two seqs at once for side-effects

2010-09-25 Thread Jeff Palmucci
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.

Something hanging onto the head?

2010-09-24 Thread Jeff Palmucci
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

Something hanging onto the head?

2010-09-23 Thread Jeff Palmucci
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

Re: Bug: contains? doesn't work on transient maps or sets

2010-08-19 Thread Jeff Palmucci
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

Re: a more general chunk-file

2010-08-17 Thread Jeff Palmucci
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

Re: Resource cleanup when lazy sequences are finalized

2010-08-13 Thread Jeff Palmucci
. 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

Re: Resource cleanup when lazy sequences are finalized

2010-08-04 Thread Jeff Palmucci
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

Re: Resource cleanup when lazy sequences are finalized

2010-08-03 Thread Jeff Palmucci
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.