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

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 h

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: 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#)

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 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 params (or

Re: a better reductions?

2009-08-09 Thread Daniel Werner
On Aug 7, 8:40 pm, Vagif Verdi 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 practical purpose

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] instea

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 alre

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 lazy

Re: Newbie code review

2009-08-09 Thread Achim Passen
Hi! If you'd like to use relational structures, take a look at clojure.set. There's a couple of functions which let you do relational algebra (project, select, rename, plus some other things like index). Clojure represents relations as sets of maps: (def data #{{:id 0 :name "Fred":age 3

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 met

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

2009-08-09 Thread Lauri Pesonen
2009/8/8 Luc Prefontaine : > 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 I don't agree with all th

Re: Question about pmap

2009-08-09 Thread Bradbev
On Aug 9, 6:08 am, Nicolas Oury 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 small ints and do

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 referenc

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

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: A clojure server

2009-08-09 Thread christian
Konrad Hinsen 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 yesterday. Appa

Re: Newbie code review

2009-08-09 Thread Jarkko Oranen
On Aug 9, 9:27 am, Chad Harrington wrote: > 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 hashm

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

2009-08-09 Thread Rich Hickey
On Aug 9, 3:37 am, John Harrop wrote: > 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 expre

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 winn

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 [n

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 seem

Re: Question about pmap

2009-08-09 Thread Johann Kraus
> Johann, if you are still following this thread, could you try running > this Clojure program on your 8 core machine? > > http://github.com/jafingerhut/clojure-benchmarks/blob/3e45bd8f6c3eba4... > > These first set of parameters below will do 8 jobs sequentially, each > doing 10^10 (inc c)'s, whe

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 wrote: > On Sat, Aug 8, 2009 at 5:23 AM, Mark Engelberg > wrote: > > > > > On Fri, Aug 7, 2009 at 5:14 PM, John Harrop wrote: > > >     (if (and (not (= 0 i)) (< (+ zr2 zi2 limit-square))) > > > I believe that (zero? i) is faster than (= 0 i). > > On primitive ints