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? Have you tested it?

I have, now, at your suggestion.  Here are the results on my iMac,
2.16 GHz Intel Core 2 Duo, Mac OS X 10.5.8, Java version:

% java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03-211)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-83, mixed mode)

All are for the mandelbrot.clj-3.clj program here:

http://github.com/jafingerhut/clojure-benchmarks/blob/3e45bd8f6c3eba47f982a0f6083493a9f076d0e9/mandelbrot/mandelbrot.clj-3.clj

(By the way, these links should not be to blank pages, as you
experienced earlier.  I can follow them when reading in the Clojure
group web page, or in my email client.  Perhaps the software you are
using to read these messages is truncating the URLs, and thus they are
not going to the intended place?  Sorry they are so long, which tends
to cause these kinds of issues.)

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
in reducing run time.

If it makes a difference, I'm also using latest github clojure and
clojure-contrib as of about August 6, 2009.  Here is what the REPL
says about the definition of zero?

% clj
Clojure 1.1.0-alpha-SNAPSHOT
user=> (use 'clojure.contrib.repl-utils)
nil
user=> (source zero?)
(defn zero?
  "Returns true if num is zero, else false"
  {:tag Boolean
   :inline (fn [x] `(. clojure.lang.Numbers (isZero ~x)))}
  [x] (. clojure.lang.Numbers (isZero x)))



using (zero? i) in dot:

real2m38.378s
user2m40.601s
sys 0m1.875s

real2m30.614s
user2m33.081s
sys 0m1.853s

using (= 0 i) in dot:

real3m18.556s
user3m20.334s
sys 0m2.060s

real3m20.425s
user3m23.392s
sys 0m1.734s

using (== 0 i) in dot:

real3m21.701s
user3m24.043s
sys 0m1.982s

real3m22.441s
user3m24.420s
sys 0m2.013s

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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, where c is a double primitive.  The second will
> do the 8 jobs in parallel, hopefully finishing about 8 times faster on
> your machine:
>
> java -cp  clojure.main pmap-testing.clj double2 8
> 100 1
> java -cp  clojure.main pmap-testing.clj double2 8
> 100 8

Ok these are the results on my machine ((*) denotes the value of the
last parameter):

sequential (1) : "Elapsed time: 112843.711514 msecs"
parallel (8) : "Elapsed time: 28347.267593 msecs"

while using 800% CPU in case of parallel (8).

I tried with changing the last parameter and these are the results:

parallel (2) : "Elapsed time: 75269.155776 msecs"
parallel (3) : "Elapsed time: 47145.931658 msecs"
parallel (4) : "Elapsed time: 37715.217599 msecs"
parallel (5) : "Elapsed time: 37839.950079 msecs"
parallel (6) : "Elapsed time: 38357.797175 msecs"
parallel (7) : "Elapsed time: 37756.190205 msecs"

>From 4 to 7 there is no speedup at all.

> If you replace double2 with double1, it should reproduce your initial
> test case with (inc 0.1) in the inner loop -- the one that started
> this thread about why there wasn't much speedup.

Results for double1:

sequential (1) : "Elapsed time: 776338.624798 msecs"
parallel (8) : "Elapsed time: 578037.874598 msecs"

> I created some Clojure and Java functions that are as similar as I
> know how to make them, but frankly I don't really know whether my JVM
> implementation (Apple's java 1.6.0_13) is using 'new Double', or a
> cache as mentioned by John Harrop earlier in this discussion, in its
> implementation of Double.valueOf(double).  I've found that the
> performance is very similar to a Java program that uses 'new Double'
> explicitly in its inner loop.

I changed my example for Java threads to just do a new Double and a
new Integer in the loop. In this case there is both times no speedup
at all. So I think Java does not parallelize well with lots of objects
handled by each thread. So this is really a Java problem, but I did
not find a discussion about this issue in Java forums.

But there remains an open issue for Clojure:

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?

By the way GC is running periodically, but while profiling it does not
report more than 1 sec of total runtime.

--
Johann
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 confirmation that it is a memory allocation related problem.
(I think for some reason, this is store as a long, the same size as a
double).

This can means two things:
 - as I hypothesized before, we are measuring the memory bandwidth
 - we fill the Thread Local Heap so fast, that there is a lock
contention for the common heap.

I don't know how to separate one from the another...

Best,

Nicolas.


> By the way GC is running periodically, but while profiling it does not
> report more than 1 sec of total runtime.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 [name,
age].  I then create an index on the age column.  The index should yield a
row-id for the given age value.  My code below works as designed, but I'd
like to see how the age-index could be improved.

Thanks for your insights.

Chad
 code begin 
(use '[clojure.contrib.seq-utils :only (flatten)])

(def data {
   0 ["Fred" 30],
   1 ["Wilma" 26],
   2 ["Bam-bam" 2],
   3 ["Dino" 3]})

(def age-index
  (apply sorted-map
 (flatten (map #(list
 (nth (val %) 1)
 (key %))
   data

(defn name-by-age [age]
  (first (data (age-index age

(println (name-by-age 26))
-- code end ---

Chad Harrington
chad.harring...@gmail.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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
> in reducing run time.
>

That's very surprising. Were you using -server in the vm options? It seems
to me that (= 0 i) for a primitive int i ought to be very fast, compared to
a Java method call that presumably takes a Number (and so would box the
int).

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 expression, as indicated below.  (zero? i) is a clear winner
> > in reducing run time.
>
> That's very surprising. Were you using -server in the vm options? It seems
> to me that (= 0 i) for a primitive int i ought to be very fast, compared to
> a Java method call that presumably takes a Number (and so would box the
> int).

That's why speculating is a waste of time.

zero? is preferred.

Rich

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 hashmap.  Each row has a row-id and and a vector of data [name,
> age].  I then create an index on the age column.  The index should yield a
> row-id for the given age value.  My code below works as designed, but I'd
> like to see how the age-index could be improved.
>
> Thanks for your insights.
>
> Chad
>  code begin 
> (use '[clojure.contrib.seq-utils :only (flatten)])
>
> (def data {
>            0 ["Fred" 30],
>            1 ["Wilma" 26],
>            2 ["Bam-bam" 2],
>            3 ["Dino" 3]})
>
> (def age-index
>   (apply sorted-map
>          (flatten (map #(list
>                          (nth (val %) 1)
>                          (key %))
>                        data

The intent of the mapping can be made clearer with destructuring I
think. Also, flatten is not needed: a core function called "into" will
transform a sequence of key/value pairs into a map.

(def age-index
  (into (sorted-map)
(map (fn [[k [name age]]] [age k]) data)))

> (defn name-by-age [age]
>   (first (data (age-index age
>
> (println (name-by-age 26))
> -- code end ---
>
> Chad Harrington
> chad.harring...@gmail.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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. Apparently all those headers and  
> libraries are for JNI, which works quite differently under MacOS,  
> where all that is part of the JavaVM framework. Under MacOSX, there  
> is thus no JAVATOP at all.
>
> I got the library to compile with:
>
> CXXFLAGS = -I/System/Library/Frameworks/JavaVM.framework/Headers - 
> DPOSIX_STRERROR_R -DSIGDANGER -DSIGMAX -DHAS_SEM_POST - 
> Dsigthreadmask=pthread_sigmask -fPIC
>
> libposix.jnilib: $(POSIX_OBJS)
>   g++ -bundle -o libposix.dnilib $(POSIX_OBJS) -lpthread
>
> I didn't find the time to test it yet though. Is there a simpler test  
> than installing and testing clj-server?
>
> Konrad.
>

Hi,

I know it's been quite some time. POSIX dependency is gone now.
It should be easier to use the server.
Just use "ant -lib cpptasks.jar dist" to build the library and
the client, run the server with

java -cp clojure.jar:clojure-server.jar clojure.main clj-server

and connect to it using clj-client.

clojure-server.jar, clj-server and clj-client can be found in the dist 
directory.

I hope it works.

Regards,

Christian

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 immutable sequence with a java interface like:

public interface FunctionalListyThing
{
Object first();
FunctionalListyThing rest();
boolean isEmpty();
}

Why does one need the 4th method, "next()" ?

thanks,
Rob

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 into an
> abstract immutable sequence with a java interface like:
>
> public interface FunctionalListyThing
> {
> Object first();
> FunctionalListyThing rest();
> boolean isEmpty();
> }
>
> Why does one need the 4th method, "next()" ?
>   


It's all about lazy vs eager sequences.

Albert

-- 
Albert Cardona
http://albert.rierol.net


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 references.

Hth, Adrian.

On Sun, Aug 9, 2009 at 5:41 PM, 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 into an
> abstract immutable sequence with a java interface like:
>
> public interface FunctionalListyThing
> {
>    Object first();
>    FunctionalListyThing rest();
>    boolean isEmpty();
> }
>
> Why does one need the 4th method, "next()" ?
>
> thanks,
> Rob
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 doing a new Integer for larger
> > ones?
>
> It seems a confirmation that it is a memory allocation related problem.
> (I think for some reason, this is store as a long, the same size as a
> double).
>
> This can means two things:
>  - as I hypothesized before, we are measuring the memory bandwidth
>  - we fill the Thread Local Heap so fast, that there is a lock
> contention for the common heap.
>
> I don't know how to separate one from the another...
You could write a task that doesn't allocate, but does hammer on
memory bandwidth & have this run in parallel at the same time.  You'd
need an array that is larger than your cache, and then stride through
it at cache line size steps.  If the runtime doesn't decrease then you
are seeing lock contention.

Cheers,
Brad
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 the points in it, and some advice is not
Clojure compatible (e.g. "do not use square brackets" and the
CL-specific block comments), I think that the guide gave me a to think
about. Something that I hadn't come across before was the use of page
breaks in source code. I also like the style of documenting a module
and all of it's public functions in the beginning of a file which then
allows the user to avoid the temptation of reading the source code
unless absolutely necessary. Also, have a look at the scheme skip list
implementation which follows the style guide:

http://mumble.net/~campbell/scheme/skip-list.scm

> Luc

-- 
  ! Lauri

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 methods.  Or it could return a simple cons
cell.  But maybe using it for both things leads to an ugly
implementation somewhere.

Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 30}
 {:id 1 :name "Wilma"   :age 26}
 {:id 2 :name "Bam-bam" :age  2}
 {:id 3 :name "Dino":age  3}})

(def age-index (clojure.set/index data [:age]))

(defn name-by-age [a]
   (map :name (age-index {:age a})))


Kind regards,
Achim


Am 09.08.2009 um 08:27 schrieb 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 [name, age].  I then create an index on the age  
> column.  The index should yield a row-id for the given age value.   
> My code below works as designed, but I'd like to see how the age- 
> index could be improved.
>
> Thanks for your insights.
>
> Chad
>  code begin 
> (use '[clojure.contrib.seq-utils :only (flatten)])
>
> (def data {
>0 ["Fred" 30],
>1 ["Wilma" 26],
>2 ["Bam-bam" 2],
>3 ["Dino" 3]})
>
> (def age-index
>   (apply sorted-map
>  (flatten (map #(list
>  (nth (val %) 1)
>  (key %))
>data
>
> (defn name-by-age [age]
>   (first (data (age-index age
>
> (println (name-by-age 26))
> -- code end ---
>
> Chad Harrington
> chad.harring...@gmail.com
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 sequences?

Here's the code for those two methods.

static public ISeq next(Object x){
if(x instanceof ISeq)
return ((ISeq) x).next();
ISeq seq = seq(x);
if(seq == null)
return null;
return seq.next();
}

static public ISeq more(Object x){
if(x instanceof ISeq)
return ((ISeq) x).more();
ISeq seq = seq(x);
if(seq == null)
return PersistentList.EMPTY;
return seq.more();
}

On Sun, Aug 9, 2009 at 11:01 AM, Adrian
Cuthbertson wrote:
>
> 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 references.
>
> Hth, Adrian.
>
> On Sun, Aug 9, 2009 at 5:41 PM, Rob wrote:
>>
>> Hi all,
>>
>> I'm trying to understand the next vs rest functions.  I don't see why
>> you want/need both.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 posted that.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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] instead of tree keys.
The above is only a simplified example of the functionality that i
need (creating a structure using a provided seq of keys) so the "just
use (create-struct :key1 :key2 :key3)" answer is not a solution :)

The questoin may be more general: If I have a function (fn [& params]
(dosomethingwithparams))
how can I call the fn with a seq of params and achieve that it treats
is as many params instead of treating the whole seq as one param?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 purposes.

Alternatively, these variants could be included in a commented-out
form. Thus they won't get compiled and loaded, but still be a help to
the curious programmer browsing the Clojure sources.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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
> any other seq) as one element, so the resulting list will have only
> one composite key [:key1 :key2 :key3] instead of tree keys.
> The above is only a simplified example of the functionality that i
> need (creating a structure using a provided seq of keys) so the "just
> use (create-struct :key1 :key2 :key3)" answer is not a solution :)
>
> The questoin may be more general: If I have a function (fn [& params]
> (dosomethingwithparams))
> how can I call the fn with a seq of params and achieve that it treats
> is as many params instead of treating the whole seq as one param?
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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#)
c (:c mp#)] ~...@body))

Is this a more "idiomatic" solution or a more "lispy" one, or am I
laboring under a misunderstanding?

-V
On Aug 8, 5:24 pm, John Harrop  wrote:
> On Sat, Aug 8, 2009 at 9:52 AM, Rich Hickey  wrote:
>
> > On Sat, Aug 8, 2009 at 5:53 AM, Meikel Brandmeyer wrote:
> > > Hi,
>
> > > Am 08.08.2009 um 02:52 schrieb samppi:
>
> > >> Great, thanks. Is clojure.lang.Var/pushThreadBindings a public,
> > >> supported part of the API? Can I use it without fear of suddenly
> > >> dropped support?
>
> > > It is was `binding` uses internally. Unfortunately
> > > this is not exported by Clojure's public API. I -
> > > unfortunately - have to rely on this hack.
>
> > get-/push-/pop-thread-bindings wrapping Var.get/push/popThreadBindings
> > would be a welcome issue/patch.
>
> > Note the addition of getThreadBindings(), which returns a map of all
> > the current bindings. This could be used to define a
> > function-returning macro that can be used when you want to pass a
> > helper function to another thread and have it use the bindings in
> > effect at the point of its creation.
>
> It occurs to me that the above would also allow stored functions to carry
> thread-local bindings with them. The obvious application being to fix the
> interaction between thread-local bindings and lazy seqs. They could also
> potentially even be used in code run in a future.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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
attention and have stale jars laying around from a previous build. The
solution for me until now was to set up failure properties that get set when
a compile or test fails, but it is a real pain to set this up for each new
project.

Thus, Clojure Ant Tasks was born. This is very young at this point, but does
support the building and testing of Clojure 1.0-compatible projects. After
defining the tasks, you just pass them a classpath and a list of namespaces
to build/test and it will do so, failing when appropriate. Despite being
young, I wanted to release this now to get feedback from people with larger
projects than my own. Both clojure and clojure-contrib suffer from the
problem that compilation and test failures aren't reported by Ant, so it
would be great to stabilize this set of tasks and be able to take advantage
of them there. Patches, bug reports and feature requests are all very much
welcome. The code can be checked out from here:

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.

Regards,

- J.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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 I get on.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



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,
so you write another macro. Then you f, g, a and x and write
another macro As a minor point: above you probably meant
binding for a, b and c.

Having a solution, which solves this problem once and for all,
is more interesting.

Sincerely
Meikel

smime.p7s
Description: S/MIME cryptographic signature