Re: take-while2?

2010-08-08 Thread bOR_
Nice! Ran into a blogpost yesterday of someone calculating 'e', and I was fiddling around after reading that with take-while looking for a way to do exactly this. user (time (/ (apply + (repeatedly 1000 (fn [] (inc (count (take- while-acc + #( % 1) (repeatedly #(rand 1000.0))

Re: looking for a simpler implementation of a function I'm using

2010-08-08 Thread Meikel Brandmeyer
Hi, Am 08.08.2010 um 05:27 schrieb David Cabana: Using a vector instead of a list as the accumulator makes it possible to skip the mapping of reverse used in the earlier version of pw: (defn pw [f? x] (let [phi (fn [a e] (if (f? e) (cons [e] a )

Re: take-while2?

2010-08-08 Thread Steve Purcell
On 8 Aug 2010, at 04:56, Michał Marczyk wrote: Yet another version: (defn take-while-acc [f pred coll] (map (fn [_ x] x) (take-while pred (reductions f coll)) coll)) Seems to work: user (take-while-acc + #( % 100) (range)) (0 1 2 3 4 5 6 7 8 9 10 11 12 13) Delightful

Re: looking for a simpler implementation of a function I'm using

2010-08-08 Thread Daniel Janus
Here's my take using my clj-iter (http://github.com/nathell/clj-iter): (defn partition-when [pred coll] (iter (for x in coll) (for p = (when x (pred x))) (for y initially () then (if p (list x) (cons x y))) (collect (reverse y) if p) (finally-collect (reverse

Re: maven compilation of a clojure project hangs due to still running thread pools

2010-08-08 Thread Stuart Sierra
Short answer: never execute code at the top-level of your source files. Only define functions. If you have a shared constant that only needs to be evaluated once, consider using delay/force. -S On Aug 7, 4:46 am, Christian Schuhegger christian.schuheg...@gmail.com wrote: Hi all, I just had

lazy-seq realization/retention within futures

2010-08-08 Thread Ben Mabey
Hi all, I've run into an issue with a lazy-seq either being prematurely realized or having the head unwittingly retained. Reading chapter 5 in The Joy of Clojure I realize that I am breaking one of the rules (page 150 in my MEAP version): avoid binding your lazy sequences locally. That said,

Re: take-while2?

2010-08-08 Thread Andreas Liljeqvist
That's succinct :) I haven't tested it against Meikels version which seems to be based upon take-while. However I think this functionality would be nice to have in core or contrib, how do one propose it? Thanks for all contributing to this thread. btw bOR_: I was reading the same blogpost :)

Re: Implementing let-over-lambda chapter 7 badger network for sorting

2010-08-08 Thread Christian Schuhegger
Hello, after my first attempts with clojure I needed to evaluate the clojure results against pure Java results. First to make my report complete here are my OS and JVM details. I run my tests on an Ubuntu 64bit 10.04 on Intel i7 3GHz hardware with a custom compiled kernel using the BFS

Re: java.lang.OutOfMemoryError

2010-08-08 Thread atucker
So in case anyone else stumbles across this topic, I thought I'd share what little I have learned about the laziness of concat, and by extension mapcat, as used in this function. (defn json-seq [dir-name] (mapcat #(do (print f) (str/split (slurp %) #\nStatusJSONImpl)) (out-files

Re: Implementing let-over-lambda chapter 7 badger network for sorting

2010-08-08 Thread Nicolas Oury
Object vs doubles is a huge difference. In Java, you pay for compilation of a lot of small methods. Has compilation of every of your method time to happen? What part of the computation does it take? -- You received this message because you are subscribed to the Google Groups Clojure group. To

Re: take-while2?

2010-08-08 Thread gary ng
On Sat, Aug 7, 2010 at 8:56 PM, Michał Marczyk michal.marc...@gmail.com wrote: Yet another version: (defn take-while-acc [f pred coll]  (map (fn [_ x] x)       (take-while pred (reductions f coll))       coll)) Seems to work: user (take-while-acc + #( % 100) (range)) (0 1 2 3 4 5 6 7 8

Re: Implementing let-over-lambda chapter 7 badger network for sorting

2010-08-08 Thread Christian Schuhegger
I understand the differenece between Object vs doubles and in fact I do not want to point out that C is faster than Java (which it is not) but I want to see the 10:1 speed improvement between my Batcher sort implementation and the standard sort. The ellipticgroup Benchmark class is very

Re: looking for a simpler implementation of a function I'm using

2010-08-08 Thread gary ng
On Sun, Aug 8, 2010 at 12:12 AM, Meikel Brandmeyer m...@kotka.de wrote: Just for fun another low-level solution: (defn partition-when  [pred coll]  (let [step (fn [p s]               (if s                 (let [fst (first s)]                   (if (pred fst)                     [p s]    

Re: Implementing let-over-lambda chapter 7 badger network for sorting

2010-08-08 Thread Christian Schuhegger
Hi all, just out of interest I've done the tests with double arrays in Java. The results for the Arrays.sort are 1.060us. Now it's becoming interesting. The results for the Batcher sort are: 803.784ns. Already an improvement! Finally I've tried once again to do the Batcher double sort in the same

Re: Patch to make leiningen at least try to be portable...

2010-08-08 Thread Phil Hagelberg
On Mon, Jul 19, 2010 at 7:39 AM, Mike Meyer mwm-keyword-googlegroups.620...@mired.org wrote: Ok, I submitted a patch to the leiningen issue tracker on github to make the lein.sh script work on systems that aren't GNU/Linux derivatives or imitators. Since I couldn't find a place to upload the

Re: looking for a simpler implementation of a function I'm using

2010-08-08 Thread gary ng
On Sat, Aug 7, 2010 at 9:30 PM, David Cabana drcab...@gmail.com wrote: conj is not the same as append; it will insert the new element in the smart (most efficient) way. For instance: user (conj  '(1 2 3) 0) (0 1 2 3) user (conj [1 2 3] 0) [1 2 3 0] There is no performance hit from using

leiningen-war

2010-08-08 Thread rob
As far as I can tell, based on using it so far, the war plugin for leiningen requires writing a web.xml file. I was just wondering why it doesn't generate that xml file for you based on the information you've specified already in leiningen. Would that be a good contribution to make, or are there

Re: looking for a simpler implementation of a function I'm using

2010-08-08 Thread Meikel Brandmeyer
Hi, On Aug 8, 8:25 pm, gary ng garyng2...@gmail.com wrote: Interesting to know. Just curious which one is more efficient(not that I question the vector append is slow) as it would still involve some array copy and creation(though I assume it would be very efficient as it is using the very

Re: looking for a simpler implementation of a function I'm using

2010-08-08 Thread Meikel Brandmeyer
Hi, On Aug 8, 6:19 pm, gary ng garyng2...@gmail.com wrote: I wrote a similar version in F# which does have the advantage of handling infinite input or a very long partition in the sense that I can still consume the first element immediately and can skip to the second, third group ... In a