Re: How to override .toString for a struct?

2009-09-22 Thread Jarkko Oranen
On Sep 22, 2:23 am, Jung Ko wrote: > Hi, > > Can someone teach me how I can override the "toString" method for a struct ? > > Here's a code snippet that shows what I'm trying to do: > > user> (defstruct bookinfo :book :filename) > user> (struct bookinfo "hello" "world") => {:book "hello", :file

Re: Applying Java methods.

2009-09-22 Thread sross
On Sep 21, 11:35 pm, pmf wrote: > On Sep 21, 11:22 pm, sross wrote: > > > I'm looking for a bit of advice for calling a java method which has a > > few different signatures (such as Connection.prepareStatement). > > Is there a cleaner way of passing a variable number of arguments to > > the me

-> with anonymous functions

2009-09-22 Thread Roman Roelofsen
Hi there! Lets assume I have this map: user=> (def person {:name "Father" :childs [{:name "Son" :age 10}]}) Testing: user=> (-> person :childs first) {:name "Son", :age 10} Now lets filter the child map: user=> (def only-name (fn [m] (select-keys m [:name]))) user=> (-> person :childs first

Re: -> with anonymous functions

2009-09-22 Thread Christophe Grand
Hi Roman! On Tue, Sep 22, 2009 at 2:58 PM, Roman Roelofsen < roman.roelof...@googlemail.com> wrote: > > Hi there! > > Lets assume I have this map: > > user=> (def person {:name "Father" :childs [{:name "Son" :age 10}]}) > > Testing: > > user=> (-> person :childs first) > {:name "Son", :age 10} >

Re: -> with anonymous functions

2009-09-22 Thread Jarkko Oranen
On Sep 22, 3:58 pm, Roman Roelofsen wrote: > Hi there! > > Lets assume I have this map: > > user=> (def person {:name "Father" :childs [{:name "Son" :age 10}]}) > > Testing: > > user=> (-> person :childs first) > {:name "Son", :age 10} > > Now lets filter the child map: > > user=> (def only-nam

Re: Applying Java methods.

2009-09-22 Thread Chouser
On Mon, Sep 21, 2009 at 5:22 PM, sross wrote: > > Hi All, > >  I'm looking for a bit of advice for calling a java method which has a > few different signatures (such as Connection.prepareStatement). >  Is there a cleaner way of passing a variable number of arguments to > the method, such as > > (

Re: -> with anonymous functions

2009-09-22 Thread Roman Roelofsen
Thanks for the explanation! So the solution is much simpler: user=> (-> person :childs first (select-keys [:name])) {:name "Son"} Cool :-) On Sep 22, 3:26 pm, Jarkko Oranen wrote: > On Sep 22, 3:58 pm, Roman Roelofsen > wrote: > > > > > Hi there! > > > Lets assume I have this map: > > > us

Re: Q: is there a better way to do this

2009-09-22 Thread Roger Gilliar
Hi, thanks a lot. Your code looks much better than mine. But there is one part that I don't understand: (defn producer [] (if (dosync (if (not @consuming) (alter data conj 1))) (recur))) How can I be sure that no more data is added to data after @consuming was set to

Managing Clojure project files

2009-09-22 Thread Emeka
Hello All, Please make out time and check the below link. And if you consider the code there useful, I encourage you to use it. I would appreciate your comments and reviews. http://emekamicro.blogspot.com/2009/09/managing-clojure-project-files.html Regards, Emeka --~--~-~--~~--

Re: Q: How to convert a struct-map to xml and back (ignoring functions)?

2009-09-22 Thread MarkSwanson
Thanks for the link. It's a good start and it has prodded me to start analyzing clojure core and contrib code - which I'm finding are incredibly good examples of how to do 'stuff'. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Go

Re: Q: How to convert a struct-map to xml and back (ignoring functions)?

2009-09-22 Thread kyle smith
Clojure data structures can be printed to a string, and the string can be read back in as a data structure. user> (def a {:key1 "string" :key2 #{"set" "of" "strings"}}) #'user/a user> a {:key1 "string", :key2 #{"set" "strings" "of"}} user> (def b (str a)) #'user/b user> b "{:key1 \"string\", :key

Re: Managing Clojure project files

2009-09-22 Thread John Newman
Sweet! I'd like to try it out. Wondering, though, might blogspot have a feature of some sort to render the code in something more palatable? I'd like to review it but it's a pain. Thanks, On 9/22/09, Emeka wrote: > Hello All, > > Please make out time and check the below link. And if you cons

Re: How to override .toString for a struct?

2009-09-22 Thread Jung Ko
On Tue, Sep 22, 2009 at 1:31 AM, Jarkko Oranen wrote: > As Mike said, it's done by adding a method to print-method, but you > will need metadata... "structs" in clojure are nothing but an > optimisation of maps... That is, in all situations structmaps are (at > least, should be) interchangeable

Re: Q: is there a better way to do this

2009-09-22 Thread hoeck
Hi, I gave it a try to find a solution to your problem. I ended up using a single atom to hold the produced data and as means to detect that consuming started (by swapping in a fn wrapping the produced value). Don't know wether this fits your problem better than the one already posted. (def data

Re: Q: is there a better way to do this

2009-09-22 Thread Roger Gilliar
> thanks a lot. Your code looks much better than mine. But there is one > part that I don't understand: > > (defn producer [] > (if (dosync (if (not @consuming) >(alter data conj 1))) >(recur))) > > After rereading the docs several times It seems that I begin to understand h

Re: Q: is there a better way to do this

2009-09-22 Thread Mark Volkmann
On Tue, Sep 22, 2009 at 3:18 PM, Roger Gilliar wrote: > >> thanks a lot. Your code looks much better than mine. But there is one >> part that I don't understand: >> >> (defn producer [] >>  (if (dosync (if (not @consuming) >>                (alter data conj 1))) >>    (recur))) >> > After rereadi

Re: Q: is there a better way to do this

2009-09-22 Thread Dave Jack
> How can I be sure that no more data is added to data after @consuming   > was set to true ? You need to prevent the modification of consuming by using ensure rather than deref (@). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: Q: How to convert a struct-map to xml and back (ignoring functions)?

2009-09-22 Thread MarkSwanson
Thanks for the note about read-string and the example. If I only had to consider Clojure I'd probably use that. The Clojure structures are going to be persisted to/from a DB, and then also read back (and maybe updated) later using other languages. The tools I prefer to use for this are based on XM

an article about Clojure on IBM DeveloperWoks

2009-09-22 Thread Alpinweis
An article about Clojure on IBM DeveloperWoks http://www.ibm.com/developerworks/opensource/library/os-eclipse-clojure/index.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, s

Re: an article about Clojure on IBM DeveloperWoks

2009-09-22 Thread Laurent PETIT
Thanks for the links, we - Counterclockwise / clojure-dev devs - were not aware that some publicity was made for Counterclockwise on IBM DeveloperWorks ! That's cool ! Regards, -- Laurent 2009/9/23 Alpinweis > > An article about Clojure on IBM DeveloperWoks > > http://www.ibm.com/developerwo

Namespace/class visibility in eval

2009-09-22 Thread Eric Tschetter
I'm trying to create an HTTP server that is essentially a clojure REPL with some integration into some classes on the server's classpath. I've got something working, but I noticed some things that made me realize I don't quite understand the scope of namespaces/imports in clojure when eval'ing. I

New Release for Enclojure plugin - 2009-09-22

2009-09-22 Thread Eric Thorsen
New release of the Enclojure plugin for Netbeans has been released! I have moved Enclojure to github and greatly simplified the build process. See readme in the root directory of the repo for more details. http://github.com/EricThorsen/enclojure You can download the release at: http://github.com

Re: New Release for Enclojure plugin - 2009-09-22

2009-09-22 Thread Wilson MacGyver
any chance the enclojure plugin can be made available to download from the NetBeans repo? It would mean much easier for netbeans users to find and install it by simply bringing up the plugin menu from within NetBeans. Just a thought. On Tue, Sep 22, 2009 at 8:53 PM, Eric Thorsen wrote: > > New

Re: "If you wish to have a version for off-line use...

2009-09-22 Thread Julian
Did you mean this? http://clojure.googlegroups.com/web/manual.pdf On Sep 20, 4:59 am, cej38 wrote: > I was just looking through the main web page of clojure-contrib and > came across this: > > "If you wish to have a version for off-line use you can use the > download button on the  page at GitHu

Re: Namespace/class visibility in eval

2009-09-22 Thread John Harrop
On Tue, Sep 22, 2009 at 6:46 PM, Eric Tschetter wrote: > If I do just > > curl 'http://localhost:43034/1.0/cloj' -H 'content-type: > application/clojure' -d '(json-str {:howdy ["hi" 1 2 3]})' > > I get this exception > > java.lang.Exception: Unable to resolve symbol: json-str in this > context (N

Re: Q: is there a better way to do this

2009-09-22 Thread Roger Gilliar
>> .. It waits until the value is actually needed. For > more details on this, see http://ociweb.com/mark/stm/article.html. . Great article.Thanks ! Roger > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojur

Re: Q: is there a better way to do this

2009-09-22 Thread Timothy Pratley
> You need to prevent the modification of consuming by using ensure > rather than deref (@). Oh - excellent point! I didn't think of that. When it useful to be able to deref inside a dosync without ensuring? Ensure seems like a more safe default of what I'd expect from a transaction. So why not

NO_SOURCE_FILE

2009-09-22 Thread Raoul Duke
hi, is there perchance some way Clojure's REPL might be able to print out more information in such situations? i don't know what precisely the situations are. it is frustrating to not get more information to help debug something. seems like it might be about anonymous fns or some such? thanks fo

Re: NO_SOURCE_FILE

2009-09-22 Thread Timothy Pratley
There could be a verbose flag which would print the form in which the error occurs. This shouldn't be default though as the forms can be quite large. On Sep 23, 3:37 pm, Raoul Duke wrote: > hi, > > is there perchance some way Clojure's REPL might be able to print out > more information in such

Streaming Data?

2009-09-22 Thread David Nolen
Dear Clojurians, Are lazy-seqs good for streaming data that arrives at indeterminate intervals? if not any pointers about which approach to take? I'm working on a simple serial port library for Clojure and I'm trying to understand how to best model a solution. Basically serial events will happe

trouble running clojure.test

2009-09-22 Thread MarkSwanson
Hello, I'm having trouble unit testing clojure code. To be sure I'm just testing clojure.test, I'm trying to test clojure.contrib.json.read. test.clj states: ;; RUNNING TESTS ;; ;; Run tests with the function "(run-tests namespaces...)": (run-tests 'your.namespace 'some.other.namespace)