Re: Speed of clojure hash map vs java hash map

2010-12-29 Thread Jason Wolfe
> Since transients enforce single-threadedness, there's no reason to put > it in an atom.  You're right that would work for the truly > single-threaded scenario.  I'm more interested right now in the > scenario of "multi-threaded, low-contention, only occasionally need a > snapshot (for iteration w

Re: Speed of clojure hash map vs java hash map

2010-12-29 Thread Laurent PETIT
Hi Mark, I understand the value of, sometimes, comparing raw speed of simple datastructures operations. So in your example, if I understand correctly, you're not computing the time taken to compute the new value to be inserted, but rather just the time of insertion. I've seen in the past collegue

type hinting the arguments of a function ..

2010-12-29 Thread Sunil S Nandihalli
Hello everybody, I tried to do the following and I am unable to compile this. (defn v-dot-double [[^double x1 ^double y1 ^double z1] [^double x2 ^double y2 ^double z2]] (+ (* x1 x2) (* y1 y2) (* z1 z2))) Am I doing it wrong? Sunil. -- You received this message because you are subscribed to t

Re: Speed of clojure hash map vs java hash map

2010-12-29 Thread nicolas.o...@gmail.com
I never was fully convinced an atom around a functional hash was perfect for concurrency. There is no write/write or read/write concurrency possible, even on independent data. Someone was working a while ago ob TransactionalHashMap, if I recall well. Is there something already to benchmark agains

Re: type hinting the arguments of a function ..

2010-12-29 Thread B Smith-Mannschott
(In Clojure 1.3-alpha-3, which I happen to have lying around): double is a function, not a class. So, Clojure responds: CompilerException java.lang.IllegalArgumentException: Unable to resolve classname ... (defn f [^double x] x) ; does not work because double is not a class (defn f [^Doub

Re: Speed of clojure hash map vs java hash map

2010-12-29 Thread Ken Wesson
On Wed, Dec 29, 2010 at 1:08 AM, Todd wrote: > I thought it'd be interesting to look closer at the insertion times as a fx > of the size of the Map. The results are at: > > https://gist.github.com/758198 > > At first I thought I'd found something interesting, only to investigate > further and real

Re: Speed of clojure hash map vs java hash map

2010-12-29 Thread Ken Wesson
On Wed, Dec 29, 2010 at 5:13 AM, nicolas.o...@gmail.com wrote: > I never was fully convinced an atom around a functional hash was > perfect for concurrency. > > There is no write/write or read/write concurrency possible, even on > independent data. There is if you resort to (mutable) java.util.co

Re: Speed of clojure hash map vs java hash map

2010-12-29 Thread Mike Meyer
On Tue, 28 Dec 2010 22:28:54 -0800 Mark Engelberg wrote: [Standing on soapbox] > On Tue, Dec 28, 2010 at 10:15 PM, David Nolen wrote: > > Even in in a single threaded context raw insert performance isn't the final > > word. What if you want to be able to deliver a snapshot for reporting? > > W

Re: Speed of clojure hash map vs java hash map

2010-12-29 Thread Chas Emerick
On Dec 29, 2010, at 1:28 AM, Mark Engelberg wrote: > On Tue, Dec 28, 2010 at 10:15 PM, David Nolen wrote: >> Even in in a single threaded context raw insert performance isn't the final >> word. What if you want to be able to deliver a snapshot for reporting? > > What if you don't? > > Seriousl

Re: From Binary Search Trees to the Dining Philosopher

2010-12-29 Thread Laurent PETIT
Hi Todd, 2010/12/29 Todd > Thanks Ken, Mark, David and Alex for your comments regarding Binary Search > trees. I've read that thread several times, and ordered Okasaki's Purely > Functional Data Structures, too. I'll return to this a bit later. > > Meanwhile, I decided to tackle learning Clojure

Re: Speed of clojure hash map vs java hash map

2010-12-29 Thread David Nolen
On Wed, Dec 29, 2010 at 1:28 AM, Mark Engelberg wrote: > It just means I have to rethink my proselytizing strategy -- I was > definitely overselling the speed of the persistent data structures. > I agree, trying to sell persistent data structures on speed alone just doesn't make sense. Any talk

Re: type hinting the arguments of a function ..

2010-12-29 Thread David Nolen
On Wed, Dec 29, 2010 at 6:59 AM, B Smith-Mannschott wrote: > (In Clojure 1.3-alpha-3, which I happen to have lying around): > > double is a function, not a class. So, Clojure responds: > > CompilerException java.lang.IllegalArgumentException: Unable to > resolve classname ... > > (defn f [^double

Re: REQUEST for feedback on http://clojure.org

2010-12-29 Thread Shantanu Kumar
Kind of late, but I hope you can still consider this. The "latest news" section on the homepage should be marked with corresponding date against each news entry: http://clojure.org/ Regards, Shantanu On Nov 28, 10:08 am, Tom Faulhaber wrote: > Jason, > > ActuallyAlexwas a little off the mark her

Re: How to Build "Slim" Version of clojure-contrib

2010-12-29 Thread Stuart Sierra
Currently, clojure-contrib's pom.xml is configured to build source-only JARs for all libraries except those four that require ahead-of-time compilation. We are in the process of developing a unified build configuration for clojure-contrib projects, including new libraries such as core.unify and

Re: type hinting the arguments of a function ..

2010-12-29 Thread B Smith-Mannschott
On Wed, Dec 29, 2010 at 16:10, David Nolen wrote: > On Wed, Dec 29, 2010 at 6:59 AM, B Smith-Mannschott > wrote: >> >> (In Clojure 1.3-alpha-3, which I happen to have lying around): >> >> double is a function, not a class. So, Clojure responds: >> >>  CompilerException java.lang.IllegalArgumentEx

Re: "classic" clojure-contrib 1.3.0-alpha4 released

2010-12-29 Thread Stuart Sierra
Yes, see under "Possible future development" on http://dev.clojure.org/display/design/Common+Contrib+Build We have a stated goal of having "Aggregate projects that package many contrib libraries in one distribution." The process and arrangement of these aggregate projects has yet to be determi

Re: websockets w/ clojure

2010-12-29 Thread Stuart Sierra
Netty. Excellent library, great documentation, built-in websocket support. http://www.jboss.org/netty Example use from my work-in-progress, Cljque: https://github.com/stuartsierra/cljque/blob/master/modules/cljque-netty/src/main/clojure/cljque/netty/util.clj -Stuart Sierra clojure.com -- You

requiring files

2010-12-29 Thread Nicholas Wieland
Hi *, I'm a bit ashamed but considering that I'm a newbie in Clojure and a total newbie in Java there's apparently no end to this metanewbie status I'm currently in :-) I'm trying to require a file and use it from the REPL, but every time I try to call a function from this file Clojure is not ab

Re: websockets w/ clojure

2010-12-29 Thread Nuno Marques
I'm not sure if people are aware or not but websockets have been dropped from firefox and opera and they expect other browsers to follow. If you follow the links you can read the thread on the ietf mailing list where the paper aut

Re: requiring files

2010-12-29 Thread Eric Lavigne
Hi, Nicholas. I would need to see more detail in order to know what is going wrong in your case. I created a new project myself so that you can see an example that does work. First I typed this: lein new hello That created a project in the hello directory. I changed in that directory and ed

Insertion - The clojure way

2010-12-29 Thread Andreas Kostler
Hi all, I've implemented a recursive version of insertion sort as a bit of an warm up with clojure. For some reason it just doesn't "feel" right. The recursion feels forced on poor old insertion sort. This might be inherent to insertion sort. My poor clojure skills are more likely to blame, thoug

Re: type hinting the arguments of a function ..

2010-12-29 Thread David Nolen
On Wed, Dec 29, 2010 at 10:48 AM, B Smith-Mannschott wrote: > - (defn f [[^double x]] x) > The compiler (1.3) does not complain about this, though I can't say > what kind of code it generates. (I suspect it boxes x, but I don't > know.) > What did you mean by "You can't cast the contents of a sequ

Re: requiring files

2010-12-29 Thread Allen Johnson
Perhaps it has something to do with the underscore in the namespace. What if you try something like this in the repl: (require 'project-name.foo) (project-name.foo/my-fn) Allen On Wed, Dec 29, 2010 at 10:49 AM, Nicholas Wieland wrote: > Hi *, > I'm a bit ashamed but considering that I'm a newb

Re: requiring files

2010-12-29 Thread Laurent PETIT
2010/12/29 Nicholas Wieland > Hi *, > I'm a bit ashamed but considering that I'm a newbie in Clojure and a total > newbie in Java there's apparently no end to this metanewbie status I'm > currently in :-) > I'm trying to require a file and use it from the REPL, but every time I try > to call a fu

Re: Insertion - The clojure way

2010-12-29 Thread Ken Wesson
On Wed, Dec 29, 2010 at 11:14 AM, Andreas Kostler wrote: > Hi all, > I've implemented a recursive version of insertion sort as a bit of an warm up > with clojure. For some reason it just doesn't "feel" right. The recursion > feels forced on poor old insertion sort. This might be inherent to inse

Re: Insertion - The clojure way

2010-12-29 Thread Laurent PETIT
2010/12/29 Ken Wesson > On Wed, Dec 29, 2010 at 11:14 AM, Andreas Kostler > wrote: > > Hi all, > > I've implemented a recursive version of insertion sort as a bit of an > warm up with clojure. For some reason it just doesn't "feel" right. The > recursion feels forced on poor old insertion sort.

Re: Insertion - The clojure way

2010-12-29 Thread Ken Wesson
On Wed, Dec 29, 2010 at 11:42 AM, Laurent PETIT wrote: > 2010/12/29 Ken Wesson >> (defn insert-into [s x] >>  (let [[low high] (split-with #(< % x) s)] >>    (concat low [x] high))) >> >> (defn insertion-sort [s] >>  (reduce insert-into [] s)) > > Hello, just a little 0.2€ : insert-into will

Soap Client

2010-12-29 Thread Sean Devlin
Anyone know of a good soap client for Java? -- 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 unsu

Re: Insertion - The clojure way

2010-12-29 Thread Laurent PETIT
2010/12/29 Ken Wesson > On Wed, Dec 29, 2010 at 11:42 AM, Laurent PETIT > wrote: > > 2010/12/29 Ken Wesson > >> (defn insert-into [s x] > >> (let [[low high] (split-with #(< % x) s)] > >>(concat low [x] high))) > >> > >> (defn insertion-sort [s] > >> (reduce insert-into [] s)) > > > > Hel

Re: Soap Client

2010-12-29 Thread Laurent PETIT
Last time I checked, it seemed that Apache Axis was still the recommended tool. 2010/12/29 Sean Devlin > Anyone know of a good soap client for Java? > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to cloju

Re: Insertion - The clojure way

2010-12-29 Thread Ken Wesson
On Wed, Dec 29, 2010 at 11:55 AM, Laurent PETIT wrote: > > > 2010/12/29 Ken Wesson >> >> On Wed, Dec 29, 2010 at 11:42 AM, Laurent PETIT >> wrote: >> > 2010/12/29 Ken Wesson >> >> (defn insert-into [s x] >> >>  (let [[low high] (split-with #(< % x) s)] >> >>    (concat low [x] high))) >> >> >>

Re: Insertion - The clojure way

2010-12-29 Thread Laurent PETIT
2010/12/29 Ken Wesson > On Wed, Dec 29, 2010 at 11:55 AM, Laurent PETIT > wrote: > > > > > > 2010/12/29 Ken Wesson > >> > >> On Wed, Dec 29, 2010 at 11:42 AM, Laurent PETIT < > laurent.pe...@gmail.com> > >> wrote: > >> > 2010/12/29 Ken Wesson > >> >> (defn insert-into [s x] > >> >> (let [[low

Re: Soap Client

2010-12-29 Thread Allen Johnson
JAX-WS 2.1 is pretty good and included in Java 6. On Wed, Dec 29, 2010 at 11:55 AM, Sean Devlin wrote: > Anyone know of a good soap client for Java? > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojur

Re: Soap Client

2010-12-29 Thread Wilson MacGyver
give apache cxf a shot http://cxf.apache.org/ On Wed, Dec 29, 2010 at 11:55 AM, Sean Devlin wrote: > Anyone know of a good soap client for Java? -- Omnem crede diem tibi diluxisse supremum. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post

Re: Insertion - The clojure way

2010-12-29 Thread Mark Engelberg
I recommend reading: http://htdp.org/2003-09-26/Book/curriculum-Z-H-16.html#node_sec_12.2 for a detailed discussion of how to design and write insertion sort in a functional language, using linked lists and recursion. One caveat: Directly translating that code to Clojure will be problematic becau

Re: Soap Client

2010-12-29 Thread Laurent PETIT
2010/12/29 Laurent PETIT > Last time I checked, it seemed that Apache Axis was still the recommended > tool. > Sorry, Axis2 it is. > > > 2010/12/29 Sean Devlin > > Anyone know of a good soap client for Java? >> >> -- >> You received this message because you are subscribed to the Google >> Gro

Re: Speed of clojure hash map vs java hash map

2010-12-29 Thread Rich Hickey
On Dec 28, 2010, at 8:57 PM, Mark Engelberg wrote: Just for fun, I was curious to see what it would be like, performance-wise, to simulate a synchronized mutable hash map by putting a clojure hash map inside an atom, and making this accessible to Java code via the map interface. I didn't try t

Re: From Binary Search Trees to the Dining Philosopher

2010-12-29 Thread Orion Hickman
Yeah, I'm new to clojure, but your code seems a tad wonky. I just gave dining philosophers a shot in clojure, and it was 32 non-empty non- comment lines (though the printing blocks are non-atomic, so the printout, while readable, is slightly bizarre at moments). Okay, the first thing I have to say

Re: Insertion - The clojure way

2010-12-29 Thread Ken Wesson
On Wed, Dec 29, 2010 at 12:39 PM, Mark Engelberg wrote: > I recommend reading: > http://htdp.org/2003-09-26/Book/curriculum-Z-H-16.html#node_sec_12.2 > for a detailed discussion of how to design and write insertion sort in > a functional language, using linked lists and recursion. > > One caveat:

Re: From Binary Search Trees to the Dining Philosopher

2010-12-29 Thread Orion Hickman
Edit: Mine has a minor bug: The conditional in eat should be inside the same dosync as the result, so it should be: (if (not (dosync (let [first-fork @(nth...) second-fork @(nth...)] (if (and first-fork second-fork) (do (ref-set ...) (ref-set ...))) (and first

Re: Speed of clojure hash map vs java hash map

2010-12-29 Thread Mark Engelberg
Thanks for that benchmark example, Rich. One thing that really intrigues me here is that the reify version is substantially faster than the gen-class version. Is there any way to harness the speed of the reify from external Java libraries calling into Clojure, or is gen-class still pretty much th

Re: Speed of clojure hash map vs java hash map

2010-12-29 Thread Stuart Halloway
gen-class is only right when you need to do concrete inheritance. That may be true when doing Java interop, but with a well-designed Java library it doesn't have to be. Stu > Thanks for that benchmark example, Rich. One thing that really > intrigues me here is that the reify version is substa

Re: Insertion - The clojure way

2010-12-29 Thread Meikel Brandmeyer
Hi, Am 29.12.2010 um 19:36 schrieb Ken Wesson: > Who needs to muck about with the stack and recur when you've got laziness? :) Even then you have to take care, because stacking lazy seq on lazy seq on … might also result in a stackoverflow. Sincerely Meikel -- You received this message becau

Re: Insertion - The clojure way

2010-12-29 Thread Andreas Kostler
On 30/12/2010, at 2:39 AM, Mark Engelberg wrote: > I recommend reading: > http://htdp.org/2003-09-26/Book/curriculum-Z-H-16.html#node_sec_12.2 > for a detailed discussion of how to design and write insertion sort in > a functional language, using linked lists and recursion. That's what I was look

Re: Insertion - The clojure way

2010-12-29 Thread Meikel Brandmeyer
Hi, as Ken said vectors are suboptimal for insertion. You might want to look at finger trees, which support that better, IIRC. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroup

Re: requiring files

2010-12-29 Thread Nicholas Wieland
On Dec 29, 2010, at 5:21 PM, Laurent PETIT wrote: > Hello, > > I've added an entry to this in the FAQ, under the "Namespaces" section : > > http://dev.clojure.org/display/doc/FAQ Thank you. My "project-name" anyway was just a placeholder, my namespace doesn't have any underscore in it :) Sor

Re: Insertion - The clojure way

2010-12-29 Thread Ken Wesson
On Wed, Dec 29, 2010 at 4:28 PM, Meikel Brandmeyer wrote: > Hi, > > Am 29.12.2010 um 19:36 schrieb Ken Wesson: > >> Who needs to muck about with the stack and recur when you've got laziness? :) > > Even then you have to take care, because stacking lazy seq on lazy seq on … > might also result in

Re: requiring files

2010-12-29 Thread Nicholas Wieland
On Dec 29, 2010, at 5:14 PM, Eric Lavigne wrote: > Hi, Nicholas. > > I would need to see more detail in order to know what is going wrong > in your case. I created a new project myself so that you can see an > example that does work. > > First I typed this: > >lein new hello > > That crea

Re: requiring files

2010-12-29 Thread Laurent PETIT
2010/12/29 Nicholas Wieland > On Dec 29, 2010, at 5:21 PM, Laurent PETIT wrote: > > Hello, > > I've added an entry to this in the FAQ, under the "Namespaces" section : > > http://dev.clojure.org/display/doc/FAQ > > > Thank you. My "project-name" anyway was just a placeholder, my namespace > doesn

Re: Insertion - The clojure way

2010-12-29 Thread David Nolen
On Wed, Dec 29, 2010 at 5:29 PM, Ken Wesson wrote: > On Wed, Dec 29, 2010 at 4:28 PM, Meikel Brandmeyer wrote: > > Hi, > > > > Am 29.12.2010 um 19:36 schrieb Ken Wesson: > > > >> Who needs to muck about with the stack and recur when you've got > laziness? :) > > > > Even then you have to take ca

Re: requiring files

2010-12-29 Thread Laurent PETIT
New attempt: 2010/12/29 Nicholas Wieland > > On Dec 29, 2010, at 5:14 PM, Eric Lavigne wrote: > > > Hi, Nicholas. > > > > I would need to see more detail in order to know what is going wrong > > in your case. I created a new project myself so that you can see an > > example that does work. > > >

Re: requiring files

2010-12-29 Thread Ken Wesson
On Wed, Dec 29, 2010 at 5:47 PM, Laurent PETIT wrote: > invoking keywords on symbols just returns nil. I wonder why this is? It should probably throw an exception if the argument isn't some kind of a map. -- You received this message because you are subscribed to the Google Groups "Clojure" gro

Re: requiring files

2010-12-29 Thread Alex Osborne
Laurent PETIT writes: > 2010/12/29 Nicholas Wieland wrote: > > [...@slicingupeyeballs:~/kenji]$ lein repl Hehe, nice hostname. :-) > REPL started; server listening on localhost:21669. > kenji.core=> (:require 'kenji.hello) > > Stop! > Unles, *cough*, ":require" is a placeholder for

Re: Insertion - The clojure way

2010-12-29 Thread Ken Wesson
On Wed, Dec 29, 2010 at 5:45 PM, David Nolen wrote: > On Wed, Dec 29, 2010 at 5:29 PM, Ken Wesson wrote: >> >> On Wed, Dec 29, 2010 at 4:28 PM, Meikel Brandmeyer wrote: >> > Hi, >> > >> > Am 29.12.2010 um 19:36 schrieb Ken Wesson: >> > >> >> Who needs to muck about with the stack and recur when

Re: requiring files

2010-12-29 Thread Laurent PETIT
2010/12/30 Ken Wesson > On Wed, Dec 29, 2010 at 5:47 PM, Laurent PETIT > wrote: > > invoking keywords on symbols just returns nil. > > I wonder why this is? It should probably throw an exception if the > argument isn't some kind of a map. > Indeed, it's somehow a shame that neither does the `ge

Re: Insertion - The clojure way

2010-12-29 Thread Mark Engelberg
On Wed, Dec 29, 2010 at 1:29 PM, Andreas Kostler wrote: > > On 30/12/2010, at 2:39 AM, Mark Engelberg wrote: > >> I recommend reading: >> http://htdp.org/2003-09-26/Book/curriculum-Z-H-16.html#node_sec_12.2 >> for a detailed discussion of how to design and write insertion sort in >> a functional l

Re: Insertion - The clojure way

2010-12-29 Thread Ken Wesson
On Wed, Dec 29, 2010 at 6:41 PM, Mark Engelberg wrote: > On Wed, Dec 29, 2010 at 1:29 PM, Andreas Kostler > wrote: >> >> On 30/12/2010, at 2:39 AM, Mark Engelberg wrote: >> >>> I recommend reading: >>> http://htdp.org/2003-09-26/Book/curriculum-Z-H-16.html#node_sec_12.2 >>> for a detailed discuss

Re: Insertion - The clojure way

2010-12-29 Thread Mark Engelberg
Ken, I agree with your analysis, and of course, you are right that this is only interesting as an exercise, because obviously there are better ways to sort. I agree: 1. reducing with the reverse of the list is one way to get a stable sort. Another possibility is to alter the insert method so th

circular references

2010-12-29 Thread Todd
Are circular references supported in clojure? 1. create two refs user=> (def aref1 (ref {})) #'user/aref1 user=> (def aref2 (ref {})) #'user/aref2 user=> aref1 # user=> aref2 # 2. alter ref1 to have a reference to ref2 user=> (dosync (ref-set aref1 {:a aref2})) {:a #} user=> aref1 #}> user=>

Re: From Binary Search Trees to the Dining Philosopher

2010-12-29 Thread Laurent PETIT
Here's my attempt at providing a simple solution to this problem: 18 lines of code, not too bad if it's not buggy ;-) ;;; Dining philosophers. Solution using Clojure STM. ;;; What are our identities? ;;; The problem talks about forks, and philosophers. ;;; Conceptually, forks have a "taken-by

Re: From Binary Search Trees to the Dining Philosopher

2010-12-29 Thread Laurent PETIT
And here's the gist, if it's more readable : https://gist.github.com/759364 2010/12/30 Laurent PETIT > Here's my attempt at providing a simple solution to this problem: > > 18 lines of code, not too bad if it's not buggy ;-) > > ;;; Dining philosophers. Solution using Clojure STM. > ;;; What are

Re: From Binary Search Trees to the Dining Philosopher

2010-12-29 Thread Laurent PETIT
of course there's a little rampant bug, (take) should read (take (count phils) ..) not (take (* 3 (count phils)...), gist updated. 2010/12/30 Laurent PETIT > And here's the gist, if it's more readable : > https://gist.github.com/759364 > > 2010/12/30 Laurent PETIT > > Here's my attempt at provi

Re: Insertion - The clojure way

2010-12-29 Thread David Nolen
On Wed, Dec 29, 2010 at 6:09 PM, Ken Wesson wrote: > On Wed, Dec 29, 2010 at 5:45 PM, David Nolen > wrote: > > On Wed, Dec 29, 2010 at 5:29 PM, Ken Wesson wrote: > >> > >> On Wed, Dec 29, 2010 at 4:28 PM, Meikel Brandmeyer wrote: > >> > Hi, > >> > > >> > Am 29.12.2010 um 19:36 schrieb Ken Wess

Re: circular references

2010-12-29 Thread Mark Engelberg
Just a guess here, but it sounds like the infinite loop is in the printing, because you entered this in at the REPL, and not a problem with the actual creation of the circular reference. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: circular references

2010-12-29 Thread Alex Osborne
Todd writes: > 3. alter ref2 to have a reference (pointer) to ref1 > > user=> (dosync (ref-set aref2 {:a aref1})) > {:a # # # # > > > {:java.lang.StackOverflowError > > > > 4. So, I've got a stack overflow... What's the proper way to deal with > this? Are circular references like this not allo

Re: Insertion - The clojure way

2010-12-29 Thread Ken Wesson
On Wed, Dec 29, 2010 at 8:13 PM, Mark Engelberg wrote: > 2.  Your new insertion function is a reasonable way to get rid of the > laziness that breaks the function for large inputs. > Another, slightly clearer and faster way: > (defn insert [n alon] >  (loop [alon alon, result []] >    (cond >    

Re: Insertion - The clojure way

2010-12-29 Thread David Nolen
On Wed, Dec 29, 2010 at 8:13 PM, Mark Engelberg wrote: > One lesson here: Sometimes Clojure/Java's stack limitations hurt, a > lot. It's a lot harder to transform this algorithm than it ideally > should be. To be clear, the HTDP implementation of insert sort is stack-consuming in Scheme/Racket

Re: Insertion - The clojure way

2010-12-29 Thread Ken Wesson
On Wed, Dec 29, 2010 at 9:12 PM, David Nolen wrote: > On Wed, Dec 29, 2010 at 6:09 PM, Ken Wesson wrote: >> >> On Wed, Dec 29, 2010 at 5:45 PM, David Nolen >> wrote: >> > On Wed, Dec 29, 2010 at 5:29 PM, Ken Wesson wrote: >> >> >> >> On Wed, Dec 29, 2010 at 4:28 PM, Meikel Brandmeyer wrote: >>

Re: circular references

2010-12-29 Thread Ken Wesson
On Wed, Dec 29, 2010 at 9:26 PM, Alex Osborne wrote: > Todd writes: > >> 3. alter ref2 to have a reference (pointer) to ref1 >> >> user=> (dosync (ref-set aref2 {:a aref1})) >> {:a #> #> #> #> >> >> >> {:java.lang.StackOverflowError >> >> >> >> 4. So, I've got a stack overflow... What's the pro

Re: Insertion - The clojure way

2010-12-29 Thread Mark Engelberg
On Wed, Dec 29, 2010 at 7:16 PM, David Nolen wrote: > On Wed, Dec 29, 2010 at 8:13 PM, Mark Engelberg > wrote: >> >> One lesson here:  Sometimes Clojure/Java's stack limitations hurt, a >> lot.  It's a lot harder to transform this algorithm than it ideally >> should be. > > To be clear, the HTDP

Re: My first Clojure program: request for code review

2010-12-29 Thread Marek Kubica
On Thu, 23 Dec 2010 21:06:49 -0800 (PST) Benny Tsai wrote: > Sure, that would be cool :) > > Sorry for the hijack, Marek! Oh, no problem. I learn from reading discussions :) regards, Marek -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post t

Getting project with clojureql to compile

2010-12-29 Thread m7d
Hi, This is a simple question, probably something easy, but I am having a bit of trouble getting some code to compile that relies on clojureql. The error I am getting is: error: java.lang.IllegalStateException: distinct already refers to: #'clojureql.core/distinct in namespace: foo.core (core.c

Re: Getting project with clojureql to compile

2010-12-29 Thread Ken Wesson
On Wed, Dec 29, 2010 at 10:37 PM, m7d wrote: > Hi, > > This is a simple question, probably something easy, but I am having a > bit of trouble getting some code to compile that relies on clojureql. > The error I am getting is: > >  error: java.lang.IllegalStateException: distinct already refers to:

Re: circular references

2010-12-29 Thread Todd
Ken - > {:a (ref (some-object-mentioning :b)) > :b (ref (some-object-mentioning :a))} That is cool, I'll try it. Thanks for the tip! -Todd On 12/29/10 7:27 PM, Ken Wesson wrote: On Wed, Dec 29, 2010 at 9:26 PM, Alex Osborne wrote: Todd writes: 3. alter ref2 to have a reference (pointer

Compiling dynamically created namespaces, without on-disk source code?

2010-12-29 Thread kovas boguta
The compile function eats a namespace, but seems to require an actual file on the classpath. Is it possible to simply compile the namespace with the current definitions as-is, without any kind of corresponding source file on disk? For example, you create a namespace and populate it in the REPL, a

Re: Insertion - The clojure way

2010-12-29 Thread Mark Engelberg
> On Wed, Dec 29, 2010 at 8:13 PM, Mark Engelberg >> However, it should be pointed out that even this latest version >> doesn't share all the performance characteristics of the classic >> functional insertion sort given at the Htdp link.  Specifically, one >> of the (few) great things about inserti

Argument is not an array, in a function inside deftype

2010-12-29 Thread Jarl Haggerty
What is wrong with my code(bottom of post)? I keep getting this error. Line 24 is "(get-cell [x r c] 1))" in the Matrix deftype and 36 is "(print (get-cell one r c) " "))" in the first nested "doseq"s. I'm on Windows 7 with Clojure 1.2. Exception in thread "main" java.lang.IllegalArgumentExcepti

clojure can't see a method in my protocol

2010-12-29 Thread Jarl Haggerty
This code, (defprotocol Matrix (matrix-get [this c r])) (deftype Matrix2D [data height width] Matrix (matrix-get [this r c] 1)) Gives me this error Exception in thread "main" java.lang.IllegalArgumentException: Can't define method not in interfaces: matrix_get (core.clj:6) at cloj

Re: Insertion - The clojure way

2010-12-29 Thread David Nolen
On Wed, Dec 29, 2010 at 10:33 PM, Mark Engelberg > But Racket's stack is only limited by your overall memory. So if you > have enough memory to hold the list you're sorting and the sorted > list, you most likely have enough memory to hold the stack of > computations necessary to generate the lis