Re: Algebraic data types in clojure.contrib

2009-03-02 Thread Konrad Hinsen
On 02.03.2009, at 01:50, Rich Hickey wrote: I was wondering if you considered using maps or struct-maps for this. One of my pet peeves with algebraic data types is the unnamed, positional nature of the components/fields. It always bothers me you have to rename the fields in every pattern

Namespaces, use, and refer

2009-03-02 Thread Konrad Hinsen
Over the last weeks, two additions to clojure.core broke several of my library modules by introducing names into the clojure.core namespace that I was using in my libraries as well. While this kind of problem is acceptable in a pre-release development period, I don't expect it to go away

clojure macros

2009-03-02 Thread linh
hello, there are lots of good examples of clojure macros on the web, but i miss a more detailed explanation. for example what do all these special characters used inside macros really mean ` ' @ ~ # ~...@. anyone know if there's a tutorial for clojure macros (not lisp)? macros are very exotic for

Re: Laziness madness

2009-03-02 Thread Meikel Brandmeyer
Hi, Am 02.03.2009 um 06:06 schrieb max3000: Here is the code that gave me trouble: (map #(add-watch % watcher callback-fn) all-agents) This was not executing. I had to change it to the below expression: (doseq [agent all-labor-agents] (add-watch agent total-labor-agent

Re: Making agents able to temporarily yield place on thread pool

2009-03-02 Thread Anand Patil
On Mar 2, 1:16 am, MikeM michael.messini...@invista.com wrote: Not sure if I understand what you need, but could you build on the existing capability to send to the current agent: (send *agent* ...) ? You could have the agent send to itself, then exit the function with some work left to do

Re: Making agents able to temporarily yield place on thread pool

2009-03-02 Thread Anand Patil
On Mar 1, 10:58 pm, Rich Hickey richhic...@gmail.com wrote: On Mar 1, 2009, at 1:53 PM, Anand Patil wrote: I've made futures use the Agents' CachedThreadPool, which should   prevent the thread pool exhaustion (svn 1316). You shouldn't worry   about the expense of the threads, that's why

Re: Internal structure of evaluation results

2009-03-02 Thread David
Thanks for the link, Mark. I'll look into the contents. What I'm talking about, though, is not that there is no documentation, but rather I can't find my way around it very well. I only get around to Clojure every so often and I find I forget a lot, so I'd have to go through practically all the

Re: could someone explain the difference between these two error messages

2009-03-02 Thread Christophe Grand
Hello, Martin DeMello a écrit : Playing with readFileToByteArray in the repl: user= (import '(org.apache.commons.io FileUtils)) nil user= (def dawg (FileUtils/readFileToByteArray words.dawg)) java.lang.ClassCastException (NO_SOURCE_FILE:10) user= (FileUtils/readFileToByteArray

Re: Concatenating many lists (stack overflow problem)

2009-03-02 Thread Zededarian
Ah, I see. Out of curiosity, is there some design reason why clojure doesn't reduce my original function to the apply version? I mean, take the function: (loop [x '(1 2 3) fin '()] (if x (recur (cdr x) (concat fin (list x))) fin)) Will, at least if I'm interpreting your responses

Re: clojure macros

2009-03-02 Thread linh
now i've found an interesting article that describes macros in more details http://www.ociweb.com/mark/clojure/article.html#Macros On 2 Mar, 10:27, linh nguyenlinh.m...@gmail.com wrote: hello, there are lots of good examples of clojure macros on the web, but i miss a more detailed

Re: Making agents able to temporarily yield place on thread pool

2009-03-02 Thread Rich Hickey
On Mar 2, 2009, at 5:15 AM, Anand Patil wrote: On Mar 1, 10:58 pm, Rich Hickey richhic...@gmail.com wrote: On Mar 1, 2009, at 1:53 PM, Anand Patil wrote: I've made futures use the Agents' CachedThreadPool, which should prevent the thread pool exhaustion (svn 1316). You shouldn't worry

member function

2009-03-02 Thread David Sletten
Does Clojure have an analog of Lisp's MEMBER function? (member 'a '(c a f e b a b e)) = (A F E B A B E) (I'm more interested in it's use as a predicate rather than the fact that it returns a sublist when true.) find and contains? are listed under the Maps section of the data structures page

Re: Internal structure of evaluation results

2009-03-02 Thread Tom Ayerst
Hi David, I think part of the problem is that you missed the name space from the data you retrived with find-doc. meta isn't in the user namespace so you need to specify it. user= (find-doc metadata) ... - *clojure.core/*meta ([obj]) Returns the metadata of obj,

Re: member function

2009-03-02 Thread Meikel Brandmeyer
Hi David, Am 02.03.2009 um 13:54 schrieb David Sletten: Does Clojure have an analog of Lisp's MEMBER function? (member 'a '(c a f e b a b e)) = (A F E B A B E) I don't know the member function of CL, but I interpret your example, that it cuts away the head of the list until the first

Re: member function

2009-03-02 Thread David Sletten
On Mar 2, 2009, at 3:39 AM, Meikel Brandmeyer wrote: Does Clojure have an analog of Lisp's MEMBER function? (member 'a '(c a f e b a b e)) = (A F E B A B E) I don't know the member function of CL, but I interpret your example, that it cuts away the head of the list until the first

Re: member function

2009-03-02 Thread Mark Volkmann
On Mon, Mar 2, 2009 at 6:54 AM, David Sletten da...@bosatsu.net wrote: Does Clojure have an analog of Lisp's MEMBER function? (member 'a '(c a f e b a b e)) = (A F E B A B E) (I'm more interested in it's use as a predicate rather than the fact that it returns a sublist when true.) find

Re: Internal structure of evaluation results

2009-03-02 Thread Michael Wood
Hi Tom On Mon, Mar 2, 2009 at 3:13 PM, Tom Ayerst tom.aye...@gmail.com wrote: Hi David, I think part of the problem is that you missed the name space from the data you retrived with find-doc.  meta isn't in the user namespace so you need to specify it. I don't think David is having trouble

Re: member function

2009-03-02 Thread David Sletten
On Mar 2, 2009, at 4:01 AM, Mark Volkmann wrote: It's verbose in order to discourage its use since its a linear search. See the discussion about the contains? function at http://www.ociweb.com/mark/clojure/article.html#Lists and http://www.ociweb.com/mark/clojure/article.html#Sets. Ahh.

Re: Making agents able to temporarily yield place on thread pool

2009-03-02 Thread Anand Patil
On Mar 2, 12:48 pm, Rich Hickey richhic...@gmail.com wrote: On Mar 2, 2009, at 5:15 AM, Anand Patil wrote: On Mar 1, 10:58 pm, Rich Hickey richhic...@gmail.com wrote: On Mar 1, 2009, at 1:53 PM, Anand Patil wrote: I've made futures use the Agents' CachedThreadPool, which should

Re: Making agents able to temporarily yield place on thread pool

2009-03-02 Thread Anand Patil
On Mar 2, 2:34 pm, Anand Patil anand.prabhakar.pa...@gmail.com wrote: On Mar 2, 12:48 pm, Rich Hickey richhic...@gmail.com wrote: On Mar 2, 2009, at 5:15 AM, Anand Patil wrote: On Mar 1, 10:58 pm, Rich Hickey richhic...@gmail.com wrote: If you'll bear with me a bit longer- what if I set

Re: Internal structure of evaluation results

2009-03-02 Thread David
On Mar 2, 3:04 pm, Michael Wood esiot...@gmail.com wrote: I don't think David is having trouble finding the documentation for meta.  He's complaining that the output of (doc meta) does not tell you that you need to use (meta (var meta)) instead of (meta 'meta) or (meta meta). Something like

Re: new Clojure article

2009-03-02 Thread Marko Kocić
Article is a great introduction and reference to clojure. It could serve as _the_ documentation, maybe even distributed with clojure itself. I like the fact that it has right code to txt ratio. The only things missing is better organization (chapters hierarchy) and syntax highlight of code.

test-clojure: eval failure

2009-03-02 Thread Stephen C. Gilardi
A test like this in clojure.contrib.test-clojure.evaluation is currently failing: user= (eval (list + 1 2 3)) java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:0) --Steve smime.p7s Description: S/MIME cryptographic signature

Re: Laziness madness

2009-03-02 Thread Bradbev
On Mar 2, 3:29 am, Mark Volkmann r.mark.volkm...@gmail.com wrote: On Sun, Mar 1, 2009 at 11:06 PM, max3000 maxime.lar...@gmail.com wrote: Hi, I find the laziness in clojure very hard to wrap my head around. I understand the idea and it's probably nice in theory. However, in real life

Re: Namespaces, use, and refer

2009-03-02 Thread srolls
On Mon, Mar 2, 2009 at 12:53 AM, Konrad Hinsen konrad.hin...@laposte.netwrote: Over the last weeks, two additions to clojure.core broke several of my library modules by introducing names into the clojure.core namespace that I was using in my libraries as well. While this kind of problem is

Re: Namespaces, use, and refer

2009-03-02 Thread Konrad Hinsen
On Mar 2, 2009, at 18:35, srolls wrote: I think :exclude is what you want (ns my-ns (:refer-clojure :exclude [get replace])) Not quite, as exclude requires me to know what I want exclude. What I want is exclude everything that wasn't there in version X.Y. Konrad.

conditions in monad comprehensions

2009-03-02 Thread Matthew D. Swank
in clojure.contrib.monad expressions handling conditions in the monad comprehension are generated by: (defn- add-monad-step Add a monad comprehension step before the already transformed monad comprehension expression mexpr. [mexpr step] (let [[bform expr] step] (if (identical? bform

Re: Utility / Reflection functions

2009-03-02 Thread Chouser
On Sun, Mar 1, 2009 at 11:25 AM, Kearsley Schieder-Wethy turv...@gmail.com wrote: However, I'll freely admit that I'm a Java newbie.  I get the basic gist of the language, but find myself stalling when it comes to finding methods and fields on an object.  One thing that I found myself

Re: Laziness madness

2009-03-02 Thread Luc Prefontaine
In August, I was also struggling with laziness. As I went along my learning curve, I realized that much of this fog in my mind came up because I was still taking mutability of data and side effects as normal by habit. I had not spliced my thoughts while toggling between Java and Clojure, something

Re: test-clojure: eval failure

2009-03-02 Thread Frantisek Sodomka
Hmm, interesting error. After the merge of the lazy branch was everything ok, so it has to be a recent change. user= (eval (list + 1 2 3)) java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:0) user= (eval '(+ 1 2 3)) 6 user= (list + 1 2 3) (#core$_PLUS___243 clojure.core$_plus___...@153f141

Re: conditions in monad comprehensions

2009-03-02 Thread Konrad Hinsen
On 02.03.2009, at 18:48, Matthew D. Swank wrote: Why is it necessary to pass a dummy result in the conditional code: (if (identical? bform :when) (list 'm-bind `(if ~expr (~'m-result ::any) ~'m-zero) (list 'fn ['_] mexpr)) ... Why not: (if (identical?

Re: Laziness madness

2009-03-02 Thread David Powell
I felt the same way at first. I think it would help if the group shared some common, non-mathematical cases, where laziness is helpful. I've been using multiple resultset-seq to collect together matching data from different databases and stream it on through some existing Java code. It is

Re: new Clojure article

2009-03-02 Thread MikeM
I read the part of your article (on lists and vectors) that you linked to in another thread - In the list section you show the function into and conj as applied to lists, but these can also be applied to vectors and will return vectors, (into [1 2 3] [4 5]) = [1 2 3 4 5] (conj [1 2 3] 4 5) = [1

Re: new Clojure article

2009-03-02 Thread Mark Volkmann
On Mon, Mar 2, 2009 at 2:11 PM, MikeM michael.messini...@invista.com wrote: I read the part of your article (on lists and vectors) that you linked to in another thread - In the list section you show the function into and conj as applied to lists, but these can also be applied to vectors and

Re: Concatenating many lists (stack overflow problem)

2009-03-02 Thread Jason Wolfe
On Mar 2, 2009, at 2:52 AM, Zededarian wrote: Ah, I see. Out of curiosity, is there some design reason why clojure doesn't reduce my original function to the apply version? I mean, take the function: (loop [x '(1 2 3) fin '()] (if x (recur (cdr x) (concat fin (list x))) fin))

Re: Clojure desktop wallpaper request/discussion

2009-03-02 Thread Chouser
On Sun, Mar 1, 2009 at 7:22 PM, Rayne disciplera...@gmail.com wrote: I've been wishing I had one for a while now, to replace my Haskell wallpaper ;). Me and blbrown were talking in #Clojure and he suggested I make this post requesting that if anyone here has skill in image editing they could

Re: member function

2009-03-02 Thread Jason Wolfe
There's also includes? in clojure.contrib.seq-utils. -Jason On Mar 2, 6:07 am, David Sletten da...@bosatsu.net wrote: On Mar 2, 2009, at 4:01 AM, Mark Volkmann wrote: It's verbose in order to discourage its use since its a linear search. See the discussion about the contains? function

Re: test-clojure: eval failure

2009-03-02 Thread Rich Hickey
On Mar 2, 1:50 pm, Frantisek Sodomka fsodo...@gmail.com wrote: Hmm, interesting error. After the merge of the lazy branch was everything ok, so it has to be a recent change. user= (eval (list + 1 2 3)) java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:0) user= (eval '(+ 1 2 3)) 6

Re: Clojure + Terracotta = Yeah, Baby!

2009-03-02 Thread Joseph Mikhail
Amit, Is it possible to configure a video conference for the next clojure meeting? On Mar 1, 12:21 pm, Amit Rathore amitrath...@gmail.com wrote: Are any of the folks on this thread in/around the bay area? (I know Nabib is). We're having a clojure user-group meeting on the 12th of March - and

Re: Namespaces, use, and refer

2009-03-02 Thread Antony Blakey
On 02/03/2009, at 7:23 PM, Konrad Hinsen wrote: For namespaces other than clojure.core, an acceptable solution is to use the :only keyword in the :use clause of the ns macro. This just requires a bit more work in typing, but I don't see any other potential difficulty. I am currently

sequences from Enumerations

2009-03-02 Thread Mark Volkmann
Should I be able to do something like this? (doseq [table-column (- jtable .getColumnModel .getColumns)] javax.swing.JTable has a getColumnModel method that returns a TableColumnModel. TableColumnModel has a getColumns method that returns EnumerationTableColumn. I was hoping that would

Re: sequences from Enumerations

2009-03-02 Thread Brian Doyle
I had the same issue and ended up having to use enumeration-seq function. Seems strange but it worked. On Mon, Mar 2, 2009 at 4:22 PM, Mark Volkmann r.mark.volkm...@gmail.comwrote: Should I be able to do something like this? (doseq [table-column (- jtable .getColumnModel .getColumns)]

Re: new Clojure article

2009-03-02 Thread Rich Hickey
On Mar 2, 3:37 pm, Mark Volkmann r.mark.volkm...@gmail.com wrote: On Mon, Mar 2, 2009 at 2:11 PM, MikeM michael.messini...@invista.com wrote: I read the part of your article (on lists and vectors) that you linked to in another thread - In the list section you show the function into and

Re: Namespaces, use, and refer

2009-03-02 Thread Laurent PETIT
Konrad, I'm able to do that from the REPL when done one by one : (clojure.core/ns-unmap *ns* (quote filter)) (clojure.core/defn filter [] oh my!) thus correctly redefining the binding of filter for the rest of use by the ns But I can't manage to get it work from a macro (indeed not even when

Re: sequences from Enumerations

2009-03-02 Thread Stephen C. Gilardi
On Mar 2, 2009, at 6:37 PM, Brian Doyle wrote: I had the same issue and ended up having to use enumeration-seq function. Seems strange but it worked. The seq function is not able to provide a seq on either an Enumeration or an Iterator. clojure.core provides enumeration-seq and

Re: sequences from Enumerations

2009-03-02 Thread Brian Doyle
That makes sense now. Thanks for the link to the thread. On Mon, Mar 2, 2009 at 5:01 PM, Stephen C. Gilardi squee...@mac.com wrote: On Mar 2, 2009, at 6:37 PM, Brian Doyle wrote: I had the same issue and ended up having to use enumeration-seq function. Seems strange but it worked.

Re: new Clojure article

2009-03-02 Thread Mark Volkmann
On Mon, Mar 2, 2009 at 5:42 PM, Rich Hickey richhic...@gmail.com wrote: On Mar 2, 3:37 pm, Mark Volkmann r.mark.volkm...@gmail.com wrote: On Mon, Mar 2, 2009 at 2:11 PM, MikeM michael.messini...@invista.com wrote: I read the part of your article (on lists and vectors) that you linked to

Re: new Clojure article

2009-03-02 Thread MikeM
At the end of the Vectors section I say this: All the code examples provided above for lists also work for vectors. Do you think I should provide more detail than that? I missed that sentence. I think it's helpful to know that some functions return a list type when given a vector, others

So what do we want for a Cells-alike ?

2009-03-02 Thread Jeffrey Straszheim
There are a lot of toy cells implementations for Clojure, but as far as I can tell none of them are really full-production ready libraries like K. Tilton's. I'm planning on starting a GUI based project and something cell's like would be very helpful. I may end up building it myself, and am

Re: could someone explain the difference between these two error messages

2009-03-02 Thread Martin DeMello
On Mar 2, 3:36 pm, Christophe Grand christo...@cgrand.net wrote: You can access the latest exception through the var *e. eg (.printStackTrace *e) will print the whole stack trace. Worth looking is also clojure.contrib.stacktrace that tries to make Java stack traces more readable. Thanks,

Re: So what do we want for a Cells-alike ?

2009-03-02 Thread Raffael Cavallaro
On Mar 2, 10:41 pm, Jeffrey Straszheim straszheimjeff...@gmail.com wrote: First off, Clojure is not Common Lisp (to say the least), so I don't think we necessarily need to create as stateful a library as the original Cells. I've used Cells-like architectures before in GUI apps (although not

Re: Namespaces, use, and refer

2009-03-02 Thread Konrad Hinsen
On 03.03.2009, at 00:53, Laurent PETIT wrote: I'm able to do that from the REPL when done one by one : (clojure.core/ns-unmap *ns* (quote filter)) (clojure.core/defn filter [] oh my!) thus correctly redefining the binding of filter for the rest of use by the ns But I can't manage to

Re: sequences from Enumerations

2009-03-02 Thread Konrad Hinsen
On 03.03.2009, at 01:01, Stephen C. Gilardi wrote: The seq function is not able to provide a seq on either an Enumeration or an Iterator. clojure.core provides enumeration-seq and iterator-seq to create seqs on them. Yesterday I added a generic anything-to-seq multimethod to

Re: Internal structure of evaluation results

2009-03-02 Thread mac
There is meta data on var's which you need to use (meta (var sym)) to get at, but I'm under the impression that the var metadata is mostly for the benefit of the language runtime and a few core functions (like doc). The regular use of metadata I think is when you add it yourself to symbols or