Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread Meikel Brandmeyer
Hi, On 14 Apr., 01:18, Kevin Downey wrote: > I beg your pardon, if you don't understand then it must have been sent > to you in error, please accept my apologies. I'm sorry. I was confused. Here a new set of measurements with different input and different machine. Including your unrolled versio

Re: labrepl incanter IntelliJ Ubuntu 64-bit X11 error

2011-04-13 Thread peterg
Many Thanks Aaron, I see the post in the la clojure forum - "Environment variables in La Clojure REPL" It does seem to be the same issue. Should I cross-post? Cheers, --PG On Apr 14, 1:25 pm, Aaron Cohen wrote: > On Wed, Apr 13, 2011 at 9:00 PM, peterg wrote: [...] >   I can confirm that I see

Re: clojure-clr - getting started on Windows WPF

2011-04-13 Thread dmiller
Reloading will definitely cause a problem. According to MS docs: "Only one instance of the Application class can be created per AppDomain, to ensure shared access to a single set of application- scope window, property, and resource data. Consequently, the default constructor of the Application cl

Re: labrepl incanter IntelliJ Ubuntu 64-bit X11 error

2011-04-13 Thread Aaron Cohen
On Wed, Apr 13, 2011 at 9:00 PM, peterg wrote: > *I seriously believe there is a missing step in published > configuration instructions, or that a development environment being > used elsewhere on the same machine by other people testing provides a > magic fix. Hi Peter, I can confirm that I s

Re: labrepl incanter IntelliJ Ubuntu 64-bit X11 error

2011-04-13 Thread Aaron Bedra
I use Ubuntu 10.10 64 Desktop edition for all of my development. I install the oracle jdk 6. All of my dotfiles and emacs configurations are on github at http://github.com/abedra/shell-shocked. You can dig through them to see if you are missing anything, but I have never had this issue befor

Re: labrepl incanter IntelliJ Ubuntu 64-bit X11 error

2011-04-13 Thread peterg
Hi All, I rebuild a brand-spanking Ubuntu 10.10 system and tried IntelliJ and labrepl. Also tried all three JDKs (openjdk sun-java-6, andf the IntelliJ built-in) none of these worked with incanter graphics. As I reported before the graphics work fine from the command-line. *I seriously believe t

Erlangs Bin for Clojure

2011-04-13 Thread Andreas Kostler
I'm quite impressed with Erlang's Bin datatype and binary pattern matching. I've tried to replicate some of the coolness in Clojure.. So, what can you do with it? Create a bin: user> (<< 1 17 42) (1 17 42) user> (<< [0xf0f0 16] 1 17) (240 240 1 17) user> (<< "abc") (97 98 99) Mo

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread Kevin Downey
I beg your pardon, if you don't understand then it must have been sent to you in error, please accept my apologies. On a side note: what does "this asian trait" have to do with anything? On Wed, Apr 13, 2011 at 3:00 PM, Meikel Brandmeyer wrote: > Hi, > > Am 13.04.2011 um 23:44 schrieb Kevin Down

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread Meikel Brandmeyer
Hi, Am 13.04.2011 um 23:44 schrieb Kevin Downey: > https://gist.github.com/918487 I never understood this asian trait of pointing to something and then leaving the other without clue. Do you care to enlighten me, what I'm missing? Sincerely Meikel -- You received this message because you are

Re: Creating defrecords from results of a sql query

2011-04-13 Thread David Nolen
On Wed, Apr 13, 2011 at 5:39 PM, Bhinderwala, Shoeb < sabhinderw...@wellington.com> wrote: > David, > > > > Thank you for asking this question. I am not sure why I need a defrecord. I > am new to clojure and come from OO background. In Java for example one would > immediately take the result set

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread Kevin Downey
https://gist.github.com/918487 On Wed, Apr 13, 2011 at 11:56 AM, Meikel Brandmeyer wrote: > Hmm… > > I did the following timings with criterium. d is a random data structure > generated by virtue of the following function: > > user=> (defn data >         [size] >         (let [l  (rand-int size)

RE: Creating defrecords from results of a sql query

2011-04-13 Thread Bhinderwala, Shoeb
David, Thank you for asking this question. I am not sure why I need a defrecord. I am new to clojure and come from OO background. In Java for example one would immediately take the result set and convert it to objects. Is there any advantage to converting to defrecord? I read Clojure has other

Re: Working with mutable objects

2011-04-13 Thread Laurent PETIT
My take: 2011/4/13 babui > I have a project in which I have to use some java mutable objects > (e.g. a graph). > > In my code, I have some functions that get these objects and add nodes > to them, for instance: > > (defn make-graph [] returns a graph wrapped with other things) > > (defn add

Re: Creating defrecords from results of a sql query

2011-04-13 Thread David Nolen
On Wed, Apr 13, 2011 at 3:43 PM, Bhinderwala, Shoeb < sabhinderw...@wellington.com> wrote: > I am considering moving the results of with-query-results into defrecords > . What is the best way to achieve this? > > I wrote the following but it hits the limitation of 20 parameters and I get > an exc

Creating defrecords from results of a sql query

2011-04-13 Thread Bhinderwala, Shoeb
I am considering moving the results of with-query-results into defrecords. What is the best way to achieve this? I wrote the following but it hits the limitation of 20 parameters and I get an exception: (defrecord PerfRecord [perf-dt grp-id sec-id asset-class beg-mv-base end-mv-base

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread Meikel Brandmeyer
Hmm… I did the following timings with criterium. d is a random data structure generated by virtue of the following function: user=> (defn data [size] (let [l (rand-int size) l2 (/ l 2)] (repeatedly l #(array-map :a 1 :b 2 :c (vec (data l2)) The t

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread babui
On 13 abr, 20:14, Alex Robbins wrote: > That has tricked me before. The lazy one is fastest because all you > are timing is the creation of the lazy seq, not its realization. Wrap > the lazy seq in a doall inside the time macro. Didn't know. Thanks !! Now the timing of the lazy one is clearly

Re: Multimethod mock using clojure.contrib.mock

2011-04-13 Thread pba
Brian, I'm not familiar with the format of midje tests, I'll take a look and provide you a couple of samples. On Apr 12, 7:52 pm, Brian Marick wrote: > On Apr 12, 2011, at 10:29 AM, pba wrote: > > > Is it possible to mock multimethods using clojure.contrib.mock ? I'm > > testing a controller imp

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread Alex Robbins
That has tricked me before. The lazy one is fastest because all you are timing is the creation of the lazy seq, not its realization. Wrap the lazy seq in a doall inside the time macro. On Wed, Apr 13, 2011 at 12:59 PM, babui wrote: > I was asking because my timings show that the lazy version is t

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread babui
I was asking because my timings show that the lazy version is the fastest one. My (very simple & stupid) test is: (defn flatten-maps "The original one" ) (defn flatten-maps-lazy "The lazy one" ) (defn flatten-maps-eager "The eager one" ) (defn flatten-maps-r

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread mark skilbeck
(time (...)) I guess. http://clojuredocs.org/clojure_core/clojure.core/time On Wed, Apr 13, 2011 at 6:38 PM, babui wrote: > A solution using recur: > > (defn flatten-maps-recur >    ([ms]     (flatten-maps-recur ms ())) >    ([ms fl]  (if-let [[f & r] (seq ms)] >                  (recur (concat

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread babui
A solution using recur: (defn flatten-maps-recur ([ms] (flatten-maps-recur ms ())) ([ms fl] (if-let [[f & r] (seq ms)] (recur (concat (get f :c) r) (cons (dissoc f :c) fl)) fl))) Please, can you publish how are you doing your timings? Thanks, JM

Working with mutable objects

2011-04-13 Thread babui
I have a project in which I have to use some java mutable objects (e.g. a graph). In my code, I have some functions that get these objects and add nodes to them, for instance: (defn make-graph [] returns a graph wrapped with other things) (defn add-to-graph [graph n] adds n to the stru

Re: 1.3.0alpha5: gen-class, java.io.Serializable, readObject, writeObject....

2011-04-13 Thread Armando Blancas
You're right, I didn't consider that those methods are public. I don't think you're making any mistakes; that's just not supported. In you case I'd probably write a Java class with all the requirements and internally consume Clojure functions done with a simpler usage of gen- class or deftype. I cu

Re: Which classloader is used by the compiler for new forms?

2011-04-13 Thread Aaron Cohen
On Wed, Apr 13, 2011 at 4:58 AM, Konrad Hinsen wrote: > I am trying to run Clojure (1.2) under a custom classloader, setting it as > the context classloader for the current thread and using it directly to load > clojure.lang.RT. Everything works fine as long as I stick to AOT-compiled > code and s

Re: Enclojure REPL problems

2011-04-13 Thread Armando Blancas
> what makes you think posting to a general-interest list will have the effect > you desire? (LOL) Indeed. And to prove it, here's the de rigueur retort of opensourceland: you fix it. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this g

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread Baishampayan Ghose
On Wed, Apr 13, 2011 at 8:19 PM, Meikel Brandmeyer wrote: > Did you also check the eager one? Yes, I did. That one was much faster but still took double the time than mine. Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- You received this message because you are subscribed to the

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread Meikel Brandmeyer
Hi, On 13 Apr., 16:13, Baishampayan Ghose wrote: > Sorry, I checked it with incorrect data. Your solution works just > fine, only that it's slower than mine (don't know why). Did you also check the eager one? Sincerely Meikel -- You received this message because you are subscribed to the Goo

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread Baishampayan Ghose
On Wed, Apr 13, 2011 at 6:04 PM, Meikel Brandmeyer wrote: > Both work for me, although in the flatten-maps-lazy there is a typo in > the recursive call. It should be named flatten-maps-lazy there, too. Sorry, I checked it with incorrect data. Your solution works just fine, only that it's slower t

Re: 1.3.0alpha5: gen-class, java.io.Serializable, readObject, writeObject....

2011-04-13 Thread Jules
hhh... I discovered a mistake in my last attempt, which accounted for the IncompatibleClassChangeError- but I just ended up with a class without the two required methods. Do you actually have a working example from which you can post snippets ? I can't get the :private metadata tag to gene

Re: 1.3.0alpha5: gen-class, java.io.Serializable, readObject, writeObject....

2011-04-13 Thread Jules
good idea but : you can't define private methods in an interface, so I tried with public methods, but these are unsurprisingly ignore by the serialisation runtime. I tried extending an abstract class with these methods - but you are not allowed to define something as private and abstract - whic

Re: Enclojure REPL problems

2011-04-13 Thread Aaron Bedra
On 04/13/2011 08:56 AM, Ken Wesson wrote: On Wed, Apr 13, 2011 at 8:45 AM, Chas Emerick wrote: On Apr 13, 2011, at 1:08 AM, Ken Wesson wrote: Since these issues have been raised on the Enclojure Google Group by various people repeatedly over the last couple of years, to no effect, it seems th

Re: clj3D, a Clojure 3D Library

2011-04-13 Thread Alfredo
As I've said on github, this not seems to be related to clj3D. Are you sure that some hidden window has been opened behind your editor or somewhere? On Apr 13, 12:59 pm, mark skilbeck wrote: > This sounds/looks cool! However, doesn't do anything for me on Windows > (ClojureBox). > > user> (use '(

Re: Enclojure REPL problems

2011-04-13 Thread Ken Wesson
On Wed, Apr 13, 2011 at 8:45 AM, Chas Emerick wrote: > > On Apr 13, 2011, at 1:08 AM, Ken Wesson wrote: > >> Since these issues have been raised on the Enclojure Google Group by >> various people repeatedly over the last couple of years, to no effect, >> it seems that they need to be raised elsewh

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread Meikel Brandmeyer
Hi, On 13 Apr., 14:25, Baishampayan Ghose wrote: > By the way, both of your functions raised ClassCastException. Both work for me, although in the flatten-maps-lazy there is a typo in the recursive call. It should be named flatten-maps-lazy there, too. user=> (defn flatten-maps-lazy [coll]

Re: Enclojure REPL problems

2011-04-13 Thread Aaron Bedra
On 04/13/2011 08:45 AM, Chas Emerick wrote: On Apr 13, 2011, at 1:08 AM, Ken Wesson wrote: Since these issues have been raised on the Enclojure Google Group by various people repeatedly over the last couple of years, to no effect, it seems that they need to be raised elsewhere to actually get t

Re: Enclojure REPL problems

2011-04-13 Thread Chas Emerick
On Apr 13, 2011, at 1:08 AM, Ken Wesson wrote: > Since these issues have been raised on the Enclojure Google Group by > various people repeatedly over the last couple of years, to no effect, > it seems that they need to be raised elsewhere to actually get the > attention they deserve. > > Someo

Re: clojure-clr - getting started on Windows WPF

2011-04-13 Thread kjeldahl
Following up on my own subject, I've created an updated gist to run on recent builds of clojure-clr (1.3.0-master-SNAPSHOT) based on another gist I found. It's not the prettiest of code I've found, but I guess CLR's abstractions and threading models can be blamed for a lot of it. What's more annoy

Re: clj3D, a Clojure 3D Library

2011-04-13 Thread mark skilbeck
This sounds/looks cool! However, doesn't do anything for me on Windows (ClojureBox). user> (use '(clj3D fenvs viewer) :reload) Reflection warning, clj3D/fenvs.clj:489 - call to loadModel can't be resolved. Reflection warning, clj3D/fenvs.clj:509 - call to setMaterial can't be resolved. nil user> (

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread Baishampayan Ghose
On Wed, Apr 13, 2011 at 4:42 PM, Meikel Brandmeyer wrote: > However your specification was not very clear how the ordering of the > flatten should be. The above reflects the intent as far as I > understood it. Your implementation was also not clear because you mix > conj with vectors and sequences

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread Meikel Brandmeyer
Hi, haha! Golf! I haven't tested the speed, but this should be straight- forward: (defn flatten-maps-lazy [coll] (lazy-seq (when-let [s (seq coll)] (let [m (first s)] (cons (dissoc m :c) (flatten-maps (concat (get m :c) (rest s However your specification was not ver

Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-13 Thread Baishampayan Ghose
Hi, I have a peculiar sequence of nested maps which have the following structure - {:a 1 :b 1 :c []} The keys :a & :b always have scalar values but the :c key can have either an empty vector or a vector of maps of the same kind. For example - {:a 1 :b 1 :c [{:a 1 :b 1 :c [{:a 1 :b 1 :c []}]} {:

Which classloader is used by the compiler for new forms?

2011-04-13 Thread Konrad Hinsen
I am trying to run Clojure (1.2) under a custom classloader, setting it as the context classloader for the current thread and using it directly to load clojure.lang.RT. Everything works fine as long as I stick to AOT-compiled code and source code without new forms. But (new ...) fails on an