Re: idiom question: infinite sequence as data source for many threads?

2010-01-27 Thread Konrad Hinsen
On 28 Jan 2010, at 08:39, Michał Marczyk wrote: Wouldn't this make it possible for two threads to obtain the same value of (first @data-source), then send two rest messages to the agent? A ref would not have this problem, though: You are right. Refs provide synchronous access to the data sour

Re: maybe-m monad violates monad law?

2010-01-27 Thread Michał Marczyk
That's one place where the Haskell version is perhaps clearer, since Haskell's return x will never evaluate to Nothing... See [1] if you'd like to read about it. The behaviour you describe is a quirk of c.c.monads' maybe-m implementation which does not allow nil as a monadic value, since it's bein

Re: maybe-m monad violates monad law?

2010-01-27 Thread Konrad Hinsen
On 28 Jan 2010, at 03:22, Tayssir John Gabbour wrote: But the maybe-m monad seems to violate this law. For instance, when the function is inc, and the value is nil, as I demonstrate here: http://paste.lisp.org/display/94017 nil should not be considered a value in the maybe monad. It is in fact

Re: idiom question: infinite sequence as data source for many threads?

2010-01-27 Thread Michał Marczyk
2010/1/28 Konrad Hinsen : > The Clojure solution for your problem is an agent, which makes the access > thread-safe: > > user> (def data-source (agent (cycle [1 2 3]))) > #'user/data-source > user> (defn get-some-data [] (let [v (first @data-source)] (send data-source > rest) v)) Wouldn't this mak

Re: idiom question: infinite sequence as data source for many threads?

2010-01-27 Thread Konrad Hinsen
On 28 Jan 2010, at 05:21, free_variation wrote: I'm not clear on how to implement this without keeping a reference to the sequence, say in a closure. In scheme I might solve the problem using a continuation. But in clojure if I do, say: (let [my-seq (lazy-seq ...)] (defn get-some-data

Re: Why is this code causing StackOverflowError?

2010-01-27 Thread Michał Marczyk
2010/1/27 Meikel Brandmeyer : > Dang. Details matter. :-) 2010/1/27 Nebojsa Stricevic : > I've transformed algorithm to this: > > [ ... elided ... ] > > And I think, that this is real SoE, and it can calculate sum of first > 200 prime numbers in ~35 sec, on 1.4 Celeron M. I'd go as far as to

Re: Why is this code causing StackOverflowError?

2010-01-27 Thread Michał Marczyk
2010/1/27 Christophe Grand : > See > http://clj-me.cgrand.net/2009/07/30/everybody-loves-the-sieve-of-eratosthenes/ > for other impls of the SoE -- there was no transients at the time but > they are fast... and can be transientified. Oh, that's really cool, Christophe! Very elegant as well as *fa

Re: Leiningen uberjar: excluding dev-dependencies; new minus-clojure task

2010-01-27 Thread Phil Hagelberg
Perry Trolard writes: > I wasn't clear. By "development environment," I meant my `clj` script, > not any particular project per se. In my clj script, I specify a place > on the filesystem to drop jars that I want on the classpath when its > invoked; I know others have setups like this. I always p

idiom question: infinite sequence as data source for many threads?

2010-01-27 Thread free_variation
Hi, I'm a clojure noob, with a background in scheme (and functional languages). I'm looking for the "clojure way" to solve the following problem: I have an infinite sequence. I'd like to have the sequence be a source for N parallel worker threads that now and then will show up to grab a few ele

Re: performance improvments for the following code

2010-01-27 Thread Andy Fingerhut
On Jan 27, 8:21 pm, Scott wrote: > wondering if I can please get some advice on how to improve the > performance of this piece of code > > (defn select-n-tournament >   [popu fit-fn n] >   (let [k 7] >     (take n (repeatedly #(first (sort-by fit-fn > (take k (shuffle > popu)) >   ) > ) I don

performance improvments for the following code

2010-01-27 Thread Scott
wondering if I can please get some advice on how to improve the performance of this piece of code (defn select-n-tournament [popu fit-fn n] (let [k 7] (take n (repeatedly #(first (sort-by fit-fn > (take k (shuffle popu)) ) ) The profiler is telling me that first is eating up alot of

maybe-m monad violates monad law?

2010-01-27 Thread Tayssir John Gabbour
Hi, I have a problem with monads. Here's the first law which monads must fulfill (taken from 2 different tutorials): (= (m-bind (m-result value) function) (function value)) -- http://onclojure.com/2009/03/06/a-monad-tutorial-for-clojure-programmers-part-2/ (m-bind (m-result x) f) is

Re: ClojureQL insert data from map

2010-01-27 Thread Nicolas Buduroi
On Jan 27, 9:43 am, Roman Roelofsen wrote: > when querying data in clojureql, the result is a list of maps. I often > directly return this list (or a map) from my "db-logic" functions > because my domain logic operates on these maps. However, I am not able > to go the other way around, e.g. take t

Re: newbie question about ns and :require

2010-01-27 Thread Raoul Duke
On Wed, Jan 27, 2010 at 1:41 PM, Matt Revelle wrote: > In general, if you see a form that looks like it's a special language > and wouldn't evaluate its > contents before executing the form then it's a macro. but that is a chicken-egg thing where i have to experiment and fiddle and then memorize

Re: newbie question about ns and :require

2010-01-27 Thread Matt Revelle
On Jan 27, 2:32 pm, Raoul Duke wrote: > > ok, thanks, i will try to internalize that :-) > > i am not somebody who can point to languages i have defined and > implemented, so i don't have any cred, but i think the requirement > that the programmer know such details (like i have to know what is or

Re: Inconsistent behavior in 1.2.0-master w.r.t. previous versions

2010-01-27 Thread Rich Hickey
On Wed, Jan 27, 2010 at 3:29 PM, Chouser wrote: > On Wed, Jan 27, 2010 at 2:56 PM, AlexK > wrote: >> >> PersistentLists and PersistentHashSets work, but other things fail. >> >> I think i know the reason: >> Compiler.emitValue() (Compiler.java:3741-3879) is for initializing >> constant expression

Re: Full Disclojure - I Need Topics!

2010-01-27 Thread Julian Adams
+1 for debugging 2010/1/27 Joonas Pulakka > On Jan 27, 7:17 am, Mark Engelberg wrote: > > Topic idea: What is the most elegant way to write a GUI in Clojure? > > (Swing? JavaFX?) Any great contrib libraries that make GUI programming > > noticeably easier? > > I have to mention MiGLayout (http

Re: Inconsistent behavior in 1.2.0-master w.r.t. previous versions

2010-01-27 Thread Chouser
On Wed, Jan 27, 2010 at 2:56 PM, AlexK wrote: > > PersistentLists and PersistentHashSets work, but other things fail. > > I think i know the reason: > Compiler.emitValue() (Compiler.java:3741-3879) is for initializing > constant expressions, but it only adds metadata, if the value is an > instance

Re: Why is this code causing StackOverflowError?

2010-01-27 Thread Nebojsa Stricevic
I've transformed algorithm to this: (defn primes-bellow "calculates all primes bellow max" [max] (loop [numbers (vec (range 2 max)) primes [] last-p 0] (let [p (first (drop-while zero? (drop (dec last-p) numbers)))] (if (> p (. Math s

Re: Inconsistent behavior in 1.2.0-master w.r.t. previous versions

2010-01-27 Thread AlexK
user> (set! *print-meta* true) true user> '#^a symbol symbol user> '#^a (list) #^{:line 1, :tag a} (list) user> '#^a [vector] [vector] user> '#^a {:a :map} {:a :map} user> '#^a #{:a :set} #^a #{:a :set} user> '#^{:meta :map} symbol symbol user> '#^{:meta :map} (list) #^{:line 1, :meta :map} (list)

Re: Suggestion: Get rid of "java.lang.Exception: EOF while reading.."

2010-01-27 Thread Gabi
Superb. Getting a fix so fast.. Open Source at its best! I tried it. Works as expected. On Jan 27, 8:50 pm, Chouser wrote: > On Wed, Jan 27, 2010 at 1:00 PM, Rich Hickey wrote: > > > On Jan 27, 11:22 am, Chouser wrote: > >> On Wed, Jan 27, 2010 at 4:03 AM, Gabi wrote: > >> > This exception is

Re: Clojure Conference Poll

2010-01-27 Thread Luc Préfontaine
Hic ! On Wed, 2010-01-27 at 12:59 -0500, Luc Préfontaine wrote: > Then lets call it ClojureFest > > Luc > > On Wed, 2010-01-27 at 08:37 -0800, eyeris wrote: > > > Exotic? You got it! Madison, WI! Seriously, we have the best bars. See > > you guys in the fall! :) > > > > I would prefer it

Re: newbie question about ns and :require

2010-01-27 Thread Raoul Duke
On Wed, Jan 27, 2010 at 11:27 AM, Richard Newman wrote: > Simple: ns is a macro, so you don't need to quote. use and require are > functions, so you need to quote their symbol arguments. > > ns uses keywords to identify its directives (:use), and functions (use) > don't, because they're identified

Re: help with serializing/deserializing structs

2010-01-27 Thread Stuart Sierra
On Jan 26, 12:46 pm, jleehurt wrote: > When I try using deftype I get the following error: > java.lang.IllegalArgumentException: No method in multimethod 'print- > dup' for dispatch value: class user.Y__5 That's probably a bug. It should work when *print-dup* is false. -SS -- You received thi

Re: newbie question about ns and :require

2010-01-27 Thread Richard Newman
now if i only knew when to use ' or : or nothing, and which in (ns) vs. inline in the repl. Simple: ns is a macro, so you don't need to quote. use and require are functions, so you need to quote their symbol arguments. ns uses keywords to identify its directives (:use), and functions (use)

Re: Suggestion: Get rid of "java.lang.Exception: EOF while reading.."

2010-01-27 Thread Chouser
On Wed, Jan 27, 2010 at 1:00 PM, Rich Hickey wrote: > > > On Jan 27, 11:22 am, Chouser wrote: >> On Wed, Jan 27, 2010 at 4:03 AM, Gabi wrote: >> > This exception is the biggest time waster for me when working with >> > Clojure. It doesn't give you a hint of where the problem really is. >> > I st

Re: Why is this code causing StackOverflowError?

2010-01-27 Thread Meikel Brandmeyer
Hi, Am 27.01.2010 um 17:57 schrieb Michał Marczyk: > while the end result is the same, the time complexity of the algorithm > is definately not. The exact difference is calculated in Melissa E. > O'Neill's paper, "The Genuine Sieve of Eratosthenes". Dang. Details matter. Sincerely Meikel -- Y

Re: Suggestion: Get rid of "java.lang.Exception: EOF while reading.."

2010-01-27 Thread Rich Hickey
On Jan 27, 11:22 am, Chouser wrote: > On Wed, Jan 27, 2010 at 4:03 AM, Gabi wrote: > > This exception is the biggest time waster for me when working with > > Clojure. It doesn't give you a hint of where the problem really is. > > I strongly suggest to improve parse error messages to contain > >

Re: newbie question about ns and :require

2010-01-27 Thread Raoul Duke
> Thus the only time you need to use a non-vector is the map for rename, > which makes sense to me. now if i only knew when to use ' or : or nothing, and which in (ns) vs. inline in the repl. ugh. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To p

Re: making instances of a parameterised class...efficiently...

2010-01-27 Thread Chouser
On Wed, Jan 27, 2010 at 8:52 AM, Jules wrote: > > I have all the ctor arg types in my hand as well and went on to think > that I could actually write a > > (defn make-ctor [class types] ...) > > which would return me : > >  (fn [#^type1 arg1 #^type2 arg2...#^typen argn]...) > > then pass this off

Re: clojure.contrib.test-contrib.test-jmx build error

2010-01-27 Thread Phil Hagelberg
Mike Hinchey writes: > On Wed, Jan 27, 2010 at 8:38 AM, Michał Marczyk > wrote: > > I've been getting this unpleasant error building clojure.contrib recently: > > http://paste.lisp.org/display/94000 > > I wonder if there's a known issue behind it...? > > I've reported this p

Re: Suggestion: Get rid of "java.lang.Exception: EOF while reading.."

2010-01-27 Thread Vagif Verdi
+1 for paredit. Writing lisp without an IDE geared towards the language is miserable. Bracket matching is a must-have feature for lisp programmer. Higher in importance than anything else. On Jan 27, 9:48 am, Jarkko Oranen wrote: > You should really give paredit.el a go some time. It feels silly

Re: Clojure Conference Poll

2010-01-27 Thread Luc Préfontaine
Then lets call it ClojureFest Luc On Wed, 2010-01-27 at 08:37 -0800, eyeris wrote: > Exotic? You got it! Madison, WI! Seriously, we have the best bars. See > you guys in the fall! :) > > I would prefer it during the week. > > > > On Jan 22, 3:15 pm, Wilson MacGyver wrote: > > I vote let

Re: Suggestion: Get rid of "java.lang.Exception: EOF while reading.."

2010-01-27 Thread Jarkko Oranen
You should really give paredit.el a go some time. It feels silly to worry about matching parentheses nowadays. That aside, I am supportive of any improvement in either compiler or reader error messages. -- You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: Suggestion: Get rid of "java.lang.Exception: EOF while reading.."

2010-01-27 Thread Gabi
Yes Rich, Please approve this patch! On Jan 27, 6:22 pm, Chouser wrote: > On Wed, Jan 27, 2010 at 4:03 AM, Gabi wrote: > > This exception is the biggest time waster for me when working with > > Clojure. It doesn't give you a hint of where the problem really is. > > I strongly suggest to improve

Re: Why is this code causing StackOverflowError?

2010-01-27 Thread Brenton
I was about to ask the same question on this list about this code adapted from SICP section 3.5.3 (defn pi-summands [n] (cons (/ 1.0 n) (lazy-seq (map - (pi-summands (+ n 2)) which causes a stack overflow when I run (nth (pi-summands 1) 1) but it looks like you have answered

Re: Suggestion: Get rid of "java.lang.Exception: EOF while reading.."

2010-01-27 Thread Howard Lewis Ship
I too would love to see this. I can't tell you how many times I've dropped a ) from a (ns and spent forever hunting it down. On Wed, Jan 27, 2010 at 8:22 AM, Chouser wrote: > On Wed, Jan 27, 2010 at 4:03 AM, Gabi wrote: >> This exception is the biggest time waster for me when working with >> Cl

Re: Why is this code causing StackOverflowError?

2010-01-27 Thread Christophe Grand
Hi, On Wed, Jan 27, 2010 at 5:57 PM, Michał Marczyk wrote: > I've had a go at implementing an incremental SoE-like sieve in Clojure: > > http://gist.github.com/287986 > > It uses transients and appears to be quite a lot faster than the > clojure.contrib.lazy-seq/primes implementation, although re

Re: clojure.contrib.test-contrib.test-jmx build error

2010-01-27 Thread Mike Hinchey
I've reported this problem before with openjdk, but sun's jdk works. -Mike On Wed, Jan 27, 2010 at 8:38 AM, Michał Marczyk wrote: > I've been getting this unpleasant error building clojure.contrib recently: > > http://paste.lisp.org/display/94000 > > I wonder if there's a known issue behind it..

Re: Why is this code causing StackOverflowError?

2010-01-27 Thread Michał Marczyk
Meikel, while the end result is the same, the time complexity of the algorithm is definately not. The exact difference is calculated in Melissa E. O'Neill's paper, "The Genuine Sieve of Eratosthenes" [1], which also includes some highly performant implementations of incremental SoE-like prime numb

Re: making instances of a parameterised class...efficiently...

2010-01-27 Thread Konrad Hinsen
On 27 Jan 2010, at 14:52, Jules wrote: I have a requirement to pull unknown Java classes out of an Object, construct instances of them and plug these back into other Objects...efficiently... I had a similar problem recently and Rich proposed the following solution, which works fine for me:

clojure.contrib.test-contrib.test-jmx build error

2010-01-27 Thread Michał Marczyk
I've been getting this unpleasant error building clojure.contrib recently: http://paste.lisp.org/display/94000 I wonder if there's a known issue behind it...? Sincerely, Michal -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

Re: Clojure Conference Poll

2010-01-27 Thread eyeris
Exotic? You got it! Madison, WI! Seriously, we have the best bars. See you guys in the fall! :) I would prefer it during the week. On Jan 22, 3:15 pm, Wilson MacGyver wrote: > I vote let's turn this into a clojure vacation, and hold it in an > exotic location. > > Otherwise, hey, Columbus Ohio

Re: Full Disclojure - I Need Topics!

2010-01-27 Thread Joonas Pulakka
On Jan 27, 7:17 am, Mark Engelberg wrote: > Topic idea: What is the most elegant way to write a GUI in Clojure? > (Swing?  JavaFX?)  Any great contrib libraries that make GUI programming > noticeably easier? I have to mention MiGLayout (http://www.miglayout.com/) and its Clojure wrapper (http://r

Re: Suggestion: Get rid of "java.lang.Exception: EOF while reading.."

2010-01-27 Thread Chouser
On Wed, Jan 27, 2010 at 4:03 AM, Gabi wrote: > This exception is the biggest time waster for me when working with > Clojure. It doesn't give you a hint of where the problem really is. > I strongly suggest to improve parse error messages to contain > meaningful info. I just wrote a patch to LispRe

Re: ClojureQL insert data from map

2010-01-27 Thread Meikel Brandmeyer
Hi, On Jan 27, 3:43 pm, Roman Roelofsen wrote: > when querying data in clojureql, the result is a list of maps. I often > directly return this list (or a map) from my "db-logic" functions > because my domain logic operates on these maps. However, I am not able > to go the other way around, e.g.

Re: Why is this code causing StackOverflowError?

2010-01-27 Thread Meikel Brandmeyer
Hi, On Jan 27, 2:43 pm, "twitter.com/nfma" wrote: > hmm... I'm just learning clojure at the moment but by looking at code what I > see is: > > 1 - A collecting parameter called primes > 2 - A test to verify if a number is a prime by calculating the reminder of > the division with all (or some) o

making instances of a parameterised class...efficiently...

2010-01-27 Thread Jules
Guys, I'm just starting out with Clojure - so be gentle - but I am a seasoned Java developer with some LISP in the background... I'm adding Clojure to a highly concurrent and metadata driven project that I am working on, to use as a DSL - specifically a query language I have a requirement t

Re: Clojure Conference Poll

2010-01-27 Thread Jeff Schwab
Joseph Smith wrote: +1 Lincoln/Omaha Nebraska. :) Mr. Buffet? Is that you? Have you, too, decided to invest in Clojure? -- 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 post

Re: Why is this code causing StackOverflowError?

2010-01-27 Thread Nebojsa Stricevic
You are right. This isn't exactly sieve of Eratosthenes. My plan was to implement it, but instead, I wrote this, because it was simpler (at least for my knowledge of Clojure). But since it's too slow, I'll transform it to real sieve of Eratosthenes, to check it's performance. On Jan 27, 2:43 pm, "

ClojureQL insert data from map

2010-01-27 Thread Roman Roelofsen
Hi, when querying data in clojureql, the result is a list of maps. I often directly return this list (or a map) from my "db-logic" functions because my domain logic operates on these maps. However, I am not able to go the other way around, e.g. take the map and tell clojureql to insert/update a ta

Re: Why is this code causing StackOverflowError?

2010-01-27 Thread twitter.com/nfma
hmm... I'm just learning clojure at the moment but by looking at code what I see is: 1 - A collecting parameter called primes 2 - A test to verify if a number is a prime by calculating the reminder of the division with all (or some) of the primes already found 3 - if a number is a prime then its a

Re: Announcement: Vijual Graph Layout Library for Clojure Version 0.1

2010-01-27 Thread Conrad
Let me think about the points you make in this post and I'll shoot you an email in the next day or so to see if I can get a better understanding of what you need. -Conrad On Jan 27, 5:49 am, Jeff Rose wrote: > I've only just skimmed the code, but it seems supporting multiple > rendering layers c

Re: Why is this code causing StackOverflowError?

2010-01-27 Thread Meikel Brandmeyer
Hi, On Jan 26, 5:38 pm, "twitter.com/nfma" wrote: > You can use the sieve of Eratosthenes... This actually is the sieve of Eratosthenes. If one really wants to go out of one's way, one can investigate the sieve of Atkin (or other improved variants) and the the various ways of optimising the alg

Re: Announcement: Vijual Graph Layout Library for Clojure Version 0.1

2010-01-27 Thread Jeff Rose
I've only just skimmed the code, but it seems supporting multiple rendering layers could be a good candidate for using either multi- methods or protocols and types What information is needed by the layout algorithms? I would guess that it basically needs a bounding box and a neighbor list for each

Re: Class of a wicket page

2010-01-27 Thread Chris Kent
I think the problem is that cwicket.HomePage resolves to a class object (like cwicket.HomePage.class in Java).  So (class cwicket.HomePage) returns the class of the class object which is java.lang.Class.  And that's not a subclass of Wicket's WebPage.  Try this:   (defn -getHomePage [this] cwicket.

Re: Remote swank cannot recconnect

2010-01-27 Thread Lukas Lehner
Hi Kyle Making a new ssh tunnel is a sure thing. The bad part was that the swank server got "deaf". I could see agents still running (unix screen is cool) but I could not connect to is again. As of open ports, luckily there is a firewall on the machine so only selected ports are exposed. Any

Suggestion: Get rid of "java.lang.Exception: EOF while reading.."

2010-01-27 Thread Gabi
This exception is the biggest time waster for me when working with Clojure. It doesn't give you a hint of where the problem really is. I strongly suggest to improve parse error messages to contain meaningful info. -- You received this message because you are subscribed to the Google Groups "Cloju

Re: Remote swank cannot recconnect

2010-01-27 Thread Lukas Lehner
Hi Anders Thanks, that did it! Now just reconnect and I can continue from where I was cut off. L On 1/26/2010 4:43 PM, Anders Rune Jensen wrote: Hi You need :dont-close true in (start-server. On Tue, Jan 26, 2010 at 3:07 PM, Lukas Lehner wrote: Hi All I've setup slime to remote repl

Re: Cyclic require

2010-01-27 Thread Michael Wood
2010/1/27 Seth : > Michael, > > Thank you for pointing this out to me. After some thinking, I decided > to lump all the defprotocols in one file; having all the APIs in one > place seemed handy. But using (load) made it possible to keep deftype > in its own file... though I did have to resort to (u