Re: Clojure performance tests and clojure a little slower than Java

2009-08-09 Thread Andy Fingerhut
On Aug 8, 2:16 pm, John Harrop jharrop...@gmail.com wrote: On Sat, Aug 8, 2009 at 5:23 AM, Mark Engelberg mark.engelb...@gmail.comwrote: On Fri, Aug 7, 2009 at 5:14 PM, John Harropjharrop...@gmail.com wrote:     (if (and (not (= 0 i)) ( (+ zr2 zi2 limit-square))) I believe that

Re: Question about pmap

2009-08-09 Thread Nicolas Oury
If I do my pmaptest with a very large Integer (inc 20) instead of (inc 0), it is as slow as the double version. My question is, whether Clojure may has a special handling for small integers? Like using primitives for small ints and doing a new Integer for larger ones? It seems a

Newbie code review

2009-08-09 Thread Chad Harrington
Hi all, I am learning Clojure and would like to see if there is a better/more concise/faster/more idiomatic/etc. way to create the age-index below. My version seems awfully roundabout. The basic concept is a toy database table stored as a hashmap. Each row has a row-id and and a vector of data

Re: Clojure performance tests and clojure a little slower than Java

2009-08-09 Thread John Harrop
On Sun, Aug 9, 2009 at 3:06 AM, Andy Fingerhut andy_finger...@alum.wustl.edu wrote: I did two runs for each version, with the only difference between them being replacing the (zero? i) expression in function 'dot' with a different expression, as indicated below. (zero? i) is a clear winner

Re: A clojure server

2009-08-09 Thread christian
Konrad Hinsen konrad.hin...@laposte.net writes: On 05.04.2009, at 17:35, Christian von Essen wrote: Yeah, I'll try providing some documentation for that. As for MacOS X, I don't have any, so we have to figure it out together, or hope that anyone else knows how to do it :) I looked at this

the point of next vs rest?

2009-08-09 Thread Rob
Hi all, I'm trying to understand the next vs rest functions. I don't see why you want/need both. Is it because null is in the picture? It seems like the interface to a good old lisp list is 3 functions (car/first/ head, cdr/rest/tail, null?/empty?). I can imagine making this into an abstract

Re: the point of next vs rest?

2009-08-09 Thread Albert Cardona
Rob wrote: Hi all, I'm trying to understand the next vs rest functions. I don't see why you want/need both. Is it because null is in the picture? It seems like the interface to a good old lisp list is 3 functions (car/first/ head, cdr/rest/tail, null?/empty?). I can imagine making this

Re: the point of next vs rest?

2009-08-09 Thread Adrian Cuthbertson
Hi Rob, have a look at http://clojure.org/sequences and then on that page there's a reference to http://clojure.org/lazy, which explains the evolution of the lazy/eager sequences. Next is used for eager cases (e.g loop/recur) and rest for lazy-seq. Should make sense if you check out those

Re: Question about pmap

2009-08-09 Thread Bradbev
On Aug 9, 6:08 am, Nicolas Oury nicolas.o...@gmail.com wrote: If I do my pmaptest with a very large Integer (inc 20) instead of (inc 0), it is as slow as the double version. My question is, whether Clojure may has a special handling for small integers? Like using primitives for

Commenting Code (Was: Re: Clojure as a First Language)

2009-08-09 Thread Lauri Pesonen
2009/8/8 Luc Prefontaine lprefonta...@softaddicts.ca: I totally agree no comments is not good at all but JavaDoc style comments in Clojure ? I pray you all, please stay away of it : I was quite taken by this scheme style guide recently: http://mumble.net/~campbell/scheme/style.txt While

Re: the point of next vs rest?

2009-08-09 Thread Rob
Okay, thanks. I see that it has something to do with laziness, but I guess I need to play with some code before I really get it. In my example interface, rest() could return something that is lazy, something that doesn't decide if it's empty or has a first element, until you call one of it's

Re: the point of next vs rest?

2009-08-09 Thread Mark Volkmann
Looking at the implementation of next and rest in RT.java (see the methods next and more), the only difference between them is what they return when the result of calling seq on the argument is null. next returns null and more returns PersistentList.EMPTY. How does that relate to eager versus

Re: Question about pmap

2009-08-09 Thread Berk Özbozkurt
... parallel (6) : Elapsed time: 38357.797175 msecs parallel (7) : Elapsed time: 37756.190205 msecs From 4 to 7 there is no speedup at all. This awfully looks like you are using a core i7 with 8 threats but only 4 physical cores. What is your hardware? sorry, I found you have already

How to create structure with a seq of keys

2009-08-09 Thread Dragan Djuric
Hi, I would like to achieve something like this: (def k [:key1 :key2 :key3]) (def mystruct (create-structure k)) Unfortunately, create structure treats the whole vector of params (or any other seq) as one element, so the resulting list will have only one composite key [:key1 :key2 :key3]

Re: a better reductions?

2009-08-09 Thread Daniel Werner
On Aug 7, 8:40 pm, Vagif Verdi vagif.ve...@gmail.com wrote: I'd suggest to include into library for teaching purposes variants of unoptimized functions with a suffix -naive. Say reduction-naive. This way you could have both beautiful algorithm for teaching purposes, and optimized function for

Re: How to create structure with a seq of keys

2009-08-09 Thread David Nolen
Sounds like you want apply: (apply fn args) On Sun, Aug 9, 2009 at 4:28 PM, Dragan Djuric draga...@gmail.com wrote: Hi, I would like to achieve something like this: (def k [:key1 :key2 :key3]) (def mystruct (create-structure k)) Unfortunately, create structure treats the whole vector of

Re: binding and bundles of variables

2009-08-09 Thread jvt
When I encountered this post, my instinct was to suggest that he write a specific macro to bind these particular variables rather than depend on magic to make new bindings at run-time from symbols known only at run-time, a la: (defmacro with-a-b-c [m body] `(let [mp# ,mp] a (:a mp#) b (:b mp#)

ANN: Clojure Ant Tasks

2009-08-09 Thread J. McConnell
Most of the Ant setups I've seen for building and testing Clojure code, including some of my own, have suffered from the fact that compilation and test failures still result in a Successful build in Ant's eyes. This can be confusing at best, but can cause real problems if you aren't paying close

Re: ANN: Clojure Ant Tasks

2009-08-09 Thread Richard Newman
On 9 Aug 2009, at 8:14 PM, J. McConnell wrote: http://github.com/jmcconnell/clojure-ant-tasks/tree/master I hope someone finds some benefit from these. Let me know if you have any questions. Thanks for sharing this; I'll give it a shot (when I'm back from vacation) and let you know how

Re: binding and bundles of variables

2009-08-09 Thread Meikel Brandmeyer
Hi, Am 10.08.2009 um 03:24 schrieb jvt: (defmacro with-a-b-c [m body] `(let [mp# ,mp] a (:a mp#) b (:b mp#) c (:c mp#)] ~...@body)) Is this a more idiomatic solution or a more lispy one, or am I laboring under a misunderstanding? I find this not very elegant. Tomorrow you need b, c and d,