Book for Programming Clojure

2009-04-30 Thread anderspe

First the "Programming Clojure" by   Stuart Halloway was sad to come
April 2009, now i read
Juni, so the loong wait have been longer. i know there is a PDF
version, but i like to have a
book.

I am new to both Lisp and Clojure, but not to development.

So is there an recommendation regarding books, tutorial etc to get
into Clojure, without the
book "Programming Clojure".

Best regards
Anders



--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Git with Google Code

2009-04-30 Thread Alvaro Vilanova Vidal
Soon, we will be able to use a DVCS on Google Code :)
http://google-code-updates.blogspot.com/2009/04/mercurial-support-for-project-hosting.html

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



clojure-contrib build error

2009-04-30 Thread Hubert Iwaniuk
Hi All,

I'm newcomer to clojure.

Downloaded clojure.jar.
Decided to go with VimClojure.
So I need clojure-contrib.
svn co clojure-contrib, and failed to build.
svn co clojure, build fine retried building clojure-contrib, went fine.

It's fine by me, but I believe that is not really a good user experience to
need to build from sources just to start playing around.

It might be good to have clojure-contrib released as clojure is released.

Cheers,
   Hubert.

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure-contrib build error

2009-04-30 Thread Robert Campbell

If you're on Windows, please take a look at Clojure Box:

http://clojure.bighugh.com/

It comes with an installer which sets you up with an Emac environment
running Clojure + contrib.

It's everything you need to get up in running in minutes. This is the
path I took when I faced similar difficulties as you.

Let me know later if you need help adding in more depedencies like
Compojure or DB drivers, as I had to struggle through that a tiny bit.

Rob



On Thu, Apr 30, 2009 at 12:08 PM, Hubert Iwaniuk  wrote:
> Hi All,
>
> I'm newcomer to clojure.
>
> Downloaded clojure.jar.
> Decided to go with VimClojure.
> So I need clojure-contrib.
> svn co clojure-contrib, and failed to build.
> svn co clojure, build fine retried building clojure-contrib, went fine.
>
> It's fine by me, but I believe that is not really a good user experience to
> need to build from sources just to start playing around.
>
> It might be good to have clojure-contrib released as clojure is released.
>
> Cheers,
>    Hubert.
>
> >
>

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure-contrib build error

2009-04-30 Thread Hubert Iwaniuk
Hi Robert,

I got it running, only thing I'm saying is that it could be easier to get
clojure-contrib.
I'm running Linux and use Vim so Clojure Box is not really for me.

Thank you,
   Hubert


On Thu, Apr 30, 2009 at 12:54 PM, Robert Campbell  wrote:

>
> If you're on Windows, please take a look at Clojure Box:
>
> http://clojure.bighugh.com/
>
> It comes with an installer which sets you up with an Emac environment
> running Clojure + contrib.
>
> It's everything you need to get up in running in minutes. This is the
> path I took when I faced similar difficulties as you.
>
> Let me know later if you need help adding in more depedencies like
> Compojure or DB drivers, as I had to struggle through that a tiny bit.
>
> Rob
>
>
>
> On Thu, Apr 30, 2009 at 12:08 PM, Hubert Iwaniuk 
> wrote:
> > Hi All,
> >
> > I'm newcomer to clojure.
> >
> > Downloaded clojure.jar.
> > Decided to go with VimClojure.
> > So I need clojure-contrib.
> > svn co clojure-contrib, and failed to build.
> > svn co clojure, build fine retried building clojure-contrib, went fine.
> >
> > It's fine by me, but I believe that is not really a good user experience
> to
> > need to build from sources just to start playing around.
> >
> > It might be good to have clojure-contrib released as clojure is released.
> >
> > Cheers,
> >Hubert.
> >
> > >
> >
>
> >
>

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure-contrib build error

2009-04-30 Thread Laurent PETIT

Hi Hubert,

Howard Lewis Ship is maintaining a maven2 repository. See
http://groups.google.com/group/clojure/browse_thread/thread/ee67ca7f69bc7e82/1ab62dcf4e2b33c9?lnk=gst&q=howard%2Brepository#1ab62dcf4e2b33c9
for details,

Regards,

-- 
Laurent

2009/4/30 Hubert Iwaniuk :
> Hi Robert,
>
> I got it running, only thing I'm saying is that it could be easier to get
> clojure-contrib.
> I'm running Linux and use Vim so Clojure Box is not really for me.
>
> Thank you,
>    Hubert
>
>
> On Thu, Apr 30, 2009 at 12:54 PM, Robert Campbell  wrote:
>>
>> If you're on Windows, please take a look at Clojure Box:
>>
>> http://clojure.bighugh.com/
>>
>> It comes with an installer which sets you up with an Emac environment
>> running Clojure + contrib.
>>
>> It's everything you need to get up in running in minutes. This is the
>> path I took when I faced similar difficulties as you.
>>
>> Let me know later if you need help adding in more depedencies like
>> Compojure or DB drivers, as I had to struggle through that a tiny bit.
>>
>> Rob
>>
>>
>>
>> On Thu, Apr 30, 2009 at 12:08 PM, Hubert Iwaniuk 
>> wrote:
>> > Hi All,
>> >
>> > I'm newcomer to clojure.
>> >
>> > Downloaded clojure.jar.
>> > Decided to go with VimClojure.
>> > So I need clojure-contrib.
>> > svn co clojure-contrib, and failed to build.
>> > svn co clojure, build fine retried building clojure-contrib, went fine.
>> >
>> > It's fine by me, but I believe that is not really a good user experience
>> > to
>> > need to build from sources just to start playing around.
>> >
>> > It might be good to have clojure-contrib released as clojure is
>> > released.
>> >
>> > Cheers,
>> >    Hubert.
>> >
>> > >
>> >
>>
>>
>
>
> >
>

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure-contrib build error

2009-04-30 Thread Hubert Iwaniuk
Hi Laurent,

Thank you for information.

It would be nice if this kind of info would be available as Featured Wiki
page.

Regards,
   Hubert.


On Thu, Apr 30, 2009 at 2:33 PM, Laurent PETIT wrote:

>
> Hi Hubert,
>
> Howard Lewis Ship is maintaining a maven2 repository. See
>
> http://groups.google.com/group/clojure/browse_thread/thread/ee67ca7f69bc7e82/1ab62dcf4e2b33c9?lnk=gst&q=howard%2Brepository#1ab62dcf4e2b33c9
> for details,
>
> Regards,
>
> --
> Laurent
>
> 2009/4/30 Hubert Iwaniuk :
> > Hi Robert,
> >
> > I got it running, only thing I'm saying is that it could be easier to get
> > clojure-contrib.
> > I'm running Linux and use Vim so Clojure Box is not really for me.
> >
> > Thank you,
> >Hubert
> >
> >
> > On Thu, Apr 30, 2009 at 12:54 PM, Robert Campbell 
> wrote:
> >>
> >> If you're on Windows, please take a look at Clojure Box:
> >>
> >> http://clojure.bighugh.com/
> >>
> >> It comes with an installer which sets you up with an Emac environment
> >> running Clojure + contrib.
> >>
> >> It's everything you need to get up in running in minutes. This is the
> >> path I took when I faced similar difficulties as you.
> >>
> >> Let me know later if you need help adding in more depedencies like
> >> Compojure or DB drivers, as I had to struggle through that a tiny bit.
> >>
> >> Rob
> >>
> >>
> >>
> >> On Thu, Apr 30, 2009 at 12:08 PM, Hubert Iwaniuk 
> >> wrote:
> >> > Hi All,
> >> >
> >> > I'm newcomer to clojure.
> >> >
> >> > Downloaded clojure.jar.
> >> > Decided to go with VimClojure.
> >> > So I need clojure-contrib.
> >> > svn co clojure-contrib, and failed to build.
> >> > svn co clojure, build fine retried building clojure-contrib, went
> fine.
> >> >
> >> > It's fine by me, but I believe that is not really a good user
> experience
> >> > to
> >> > need to build from sources just to start playing around.
> >> >
> >> > It might be good to have clojure-contrib released as clojure is
> >> > released.
> >> >
> >> > Cheers,
> >> >Hubert.
> >> >
> >> > >
> >> >
> >>
> >>
> >
> >
> > >
> >
>
> >
>

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Metadata for Any Object

2009-04-30 Thread Rich Hickey



On Apr 30, 1:41 am, Laurent PETIT  wrote:
> Hi,
>
> 2009/4/30 Stuart Sierra :
>
>
>
> > On Apr 29, 5:58 pm, Stu Hood  wrote:
> >> Instead of attaching the metadata directly to the object, what if the
> >> metadata was stored outside the object, in a global map of {object 
> >> metadata,
> >> ...}? In order to handle garbage collection, something similar to Java's
> >> WeakHashMap could be used, with the object itself as the key.
>
> > Interesting idea.
>
> > There might be performance penalities, depending on how often metadata
> > is used.  Metadata guarantees atomic updates (alter-meta!) so the
> > WeakHashMap might need to be wrapped in a synchronized map, at a
> > further penalty.
>
> I guess this would not be sufficient: WeakHashMap are not side-effect
> free: they mutate every time one of their key is removed :
> "When a key has been discarded its entry is effectively removed from
> the map, so this class behaves somewhat differently than other Map
> implementations."
>
> , making them improper to be used within STM transactions and such.
>
> Regards,
>
> --
> Laurent
>
>
>
> > I've never needed metadata on non-Clojure types.  Do you have a use in
> > mind?
>
> > This could be a library, too, sort of like:
>
> > (defn my-meta [object]
> >  (if (instance? clojure.lang.IMeta object)
> >  (meta object)
> >  (*global-metadata* object)))
>

Metadata for arbitrary objects is not a supportable idea.

First off, there is the fundamental question about whether an object
is truly a value type. If it is not, metadata needs special handling,
essentially being a mutable property of the reference type, a la var/
ref/ns/agent/atom metadata.

If it is a value, then with-meta should work, returning a new value
with the metadata. But doing so for arbitrary value objects would
require a protocol for value cloning.

Then, you need to know which operations require metadata propagation.
That's built into the Clojure data structures but can't be retrofitted
to arbitrary types.

Then there are all the subtleties of metadata being associated with a
value but being recorded as associated with the identity of a value
(e.g. you might have two instances of 42 with different metadata) This
runs completely against the grain of Clojure's value-oriented
programming.

Then you get into the concurrency problems of a centralized metadata
lookup table.

Then you have the GC problems of a huge weak map.

Etc etc. It is simply unworkable IMO.

Rich

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure-contrib build error

2009-04-30 Thread Rayne

It's not really all that hard. They make it insanely easy to build.
However, Clojure is still in the "new" stage. I'm pretty sure that
soon enough we are going to need a new way to manage libraries instead
of Clojure-contrib.

On Apr 30, 5:08 am, Hubert Iwaniuk  wrote:
> Hi All,
>
> I'm newcomer to clojure.
>
> Downloaded clojure.jar.
> Decided to go with VimClojure.
> So I need clojure-contrib.
> svn co clojure-contrib, and failed to build.
> svn co clojure, build fine retried building clojure-contrib, went fine.
>
> It's fine by me, but I believe that is not really a good user experience to
> need to build from sources just to start playing around.
>
> It might be good to have clojure-contrib released as clojure is released.
>
> Cheers,
>    Hubert.
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Book for Programming Clojure

2009-04-30 Thread Rayne

http://ociweb.com/jnb/jnbMar2009.html

On Apr 30, 4:49 am, anderspe  wrote:
> First the "Programming Clojure" by   Stuart Halloway was sad to come
> April 2009, now i read
> Juni, so the loong wait have been longer. i know there is a PDF
> version, but i like to have a
> book.
>
> I am new to both Lisp and Clojure, but not to development.
>
> So is there an recommendation regarding books, tutorial etc to get
> into Clojure, without the
> book "Programming Clojure".
>
> Best regards
> Anders
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Git with Google Code

2009-04-30 Thread Rayne

I'm switching to ubuntu tonight anyways.

Still pretty upsetting that, mentioning Git sucks on windows starts a
round of "Windows sux!". :\

On Apr 29, 3:55 am, dysinger  wrote:
> Let me abstract that out a little for you :P
>
> (defn on-windows [x]
>   (format "%s sucks on windows!" x))
>
> On Apr 28, 1:36 pm, Rayne  wrote:
>
> > Git still sucks on windows :\
>
> > On Apr 28, 11:04 am, Stuart Sierra 
> > wrote:
>
> > > FYI, for those interested in using Git for Clojure sources, here's
> > > Google's advice on how to use Git with Google Code:
>
> > >http://google-opensource.blogspot.com/2008/05/develop-with-git-on-goo...
>
> > > -SS
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Book for Programming Clojure

2009-04-30 Thread anderspe

Thanks so mutch, this was great.
Best regards
Anders


On 30 Apr, 15:28, Rayne  wrote:
> http://ociweb.com/jnb/jnbMar2009.html
>
> On Apr 30, 4:49 am, anderspe  wrote:
>
>
>
> > First the "Programming Clojure" by   Stuart Halloway was sad to come
> > April 2009, now i read
> > Juni, so the loong wait have been longer. i know there is a PDF
> > version, but i like to have a
> > book.
>
> > I am new to both Lisp and Clojure, but not to development.
>
> > So is there an recommendation regarding books, tutorial etc to get
> > into Clojure, without the
> > book "Programming Clojure".
>
> > Best regards
> > Anders- Dölj citerad text -
>
> - Visa citerad text -
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Dropping strings.

2009-04-30 Thread kreso

Hi,

> Any suggestions?

You can use (.substring s n), if n is larger than string length it
will return a empty string.

--
Krešimir Šojat
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure-contrib build error

2009-04-30 Thread Julien

You can try the eclipse plug in for clojure.
It is easy to install and provided with its own clojure.jar and
clojure-contrib.jar.

here is the link: http://code.google.com/p/clojure-dev/

you will need Eclipse though.

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure-contrib build error

2009-04-30 Thread Julien

You can try the eclipse plug in for clojure.
It is easy to install and provided with its own clojure.jar and
clojure-contrib.jar.

here is the link: http://code.google.com/p/clojure-dev/

you will need Eclipse though.

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



testing the reader...

2009-04-30 Thread Julien

Hi all,


I'm currently working on a small project to get started with clojure.

I can't solve this problem which seem to be related to the reader.
So I ran some test against it.

-here's the clojure code:
(def text1 "testing thread")
(def T (proxy [Thread] []
(run []
(println "T 
thread : (eval (println text1))")
;this works 
fine so i assume the var text1 is available from
the thread
(eval (println 
text1))

(println "T 
thread : (eval (read-string \"(println
text1)\"))")
; this 
instruction seem to be causing the problem
; Unable to 
resolve symbol: text1 in this context
(eval 
(read-string "(println text1)"))
)))

(println "Main thread : (eval (println text1))")
(eval (println text1))
(println "Main thread : (eval (read-string \"(println 
text1)\"))")
(eval (read-string "(println text1)"))
(. T start)

-and the output:
Clojure
Main thread : (eval (println text1))
testing thread
Main thread : (eval (read-string "(println text1)"))
testing thread
1:1 user=> T thread : (eval (println text1))
testing thread
T thread : (eval (read-string "(println text1)"))

-followed by the stack trace
Exception in thread "Thread-1" java.lang.Exception: Unable to
resolve symbol: text1 in this context (NO_SOURCE_FILE:0)
at clojure.lang.Compiler.analyze(Compiler.java:4330)
at clojure.lang.Compiler.analyze(Compiler.java:4276)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:2761)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4488)
at clojure.lang.Compiler.analyze(Compiler.java:4315)
at clojure.lang.Compiler.analyze(Compiler.java:4276)
at 
clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:3852)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:3687)
at 
clojure.lang.Compiler$FnMethod.access$1100(Compiler.java:3564)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:2953)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4484)
at clojure.lang.Compiler.analyze(Compiler.java:4315)
at clojure.lang.Compiler.eval(Compiler.java:4520)
at clojure.core$eval__3975.invoke(core.clj:1743)
at user$fn__88$fn__90.invoke(testReader.clj:8)
at clojure.proxy.java.lang.Thread.run(Unknown Source)
Caused by: java.lang.Exception: Unable to resolve symbol: text1 in
this context
at clojure.lang.Compiler.resolveIn(Compiler.java:4671)
at clojure.lang.Compiler.resolve(Compiler.java:4617)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:4594)
at clojure.lang.Compiler.analyze(Compiler.java:4297)
... 15 more


So my question is would it be possible to get access to text1 in the
thread using this code (eval (read-string "(println text1)"))?

Is the reader really involved in this?


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Book for Programming Clojure

2009-04-30 Thread Mark Volkmann

Make sure you read the more recently updated version at
http://ociweb.com/mark/clojure/article.html. The "jnb" URL listed
below has a link to the newest version near the beginning.

For a list of the changes that have been made to this article since it
was first released, see http://ociweb.com/mark/clojure/.

On Thu, Apr 30, 2009 at 8:28 AM, Rayne  wrote:
>
> http://ociweb.com/jnb/jnbMar2009.html
>
> On Apr 30, 4:49 am, anderspe  wrote:
>> First the "Programming Clojure" by   Stuart Halloway was sad to come
>> April 2009, now i read
>> Juni, so the loong wait have been longer. i know there is a PDF
>> version, but i like to have a
>> book.
>>
>> I am new to both Lisp and Clojure, but not to development.
>>
>> So is there an recommendation regarding books, tutorial etc to get
>> into Clojure, without the
>> book "Programming Clojure".
>>
>> Best regards
>> Anders

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: The function of clojure.contrib.accumulators

2009-04-30 Thread samppi

Okay; thanks for the answer! I understand now.

On Apr 29, 11:52 pm, Konrad Hinsen  wrote:
> On 29.04.2009, at 21:44, samppi wrote:
>
> > Could someone give me a simple example of when
> > clojure.contrib.accumulators is useful? Its use seems to involve
> > collections (and numbers) that have the :clojure.contrib.accumulators/
> > accumulator type, and it has some general multimethods for adding and
> > combining, but what does it add that conj and concat do not provide?
> > contrib.monads/writer-m seems to suggest using accumulators, too...
>
> My main motivation for writing that library was to have a generic  
> interface to many kinds of accumulators for use in contrib.monads/
> writer-m. The writer monad is of little use if a specific type of  
> accumulator is hard-coded into it, as different applications need to  
> accumulate quite different data items. The same need for a generic  
> interface exists in other situations. For example, in one of my  
> applications I have a tree data structure with a generic "accumulate  
> leaf values" operation that uses the accumulator multimethods.
>
> In addition to the generic accumulator interface, the accumulator  
> library contains implementations of non-trivial accumulators such as  
> counter, min-max, or mean-variance. I use these three a lot for  
> statistics, with counter for producing histograms.
>
> Konrad.
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Macro newbie: calling another macro

2009-04-30 Thread samppi

I'm having trouble trying to create a macro that calls domonad with
one argument already filled in: (domonad parser-m rest-of-arguments).
parser-m is a monad defined in the same namespace. This is what I have
right now:
  (defmacro complex
[steps & product-expr]
`(domonad ~parser-m ~steps ~product-expr))

It's giving me this kind of error:
  Exception in thread "main" java.lang.ExceptionInInitializerError
(test_parse.clj:0)

If I try it without the quotes:
  (defmacro complex
[steps & product-expr]
(domonad parser-m steps product-expr))

I get this error:
  Exception in thread "main" java.lang.UnsupportedOperationException:
count not supported on this type: Symbol (fnparse.clj:55)

What can I do to get complex to call domonad with parser-m, delegating
what arguments it gets to domonad?


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Macro newbie: calling another macro

2009-04-30 Thread Meikel Brandmeyer

Hi,

Am 30.04.2009 um 17:39 schrieb samppi:


 (defmacro complex
   [steps & product-expr]
   `(domonad ~parser-m ~steps ~product-expr))


Just leave out the ~ in front of parser-m. And
I'm not sure how you want to handle product-expr.
Maybe a @ is also missing here.

 (defmacro complex
   [steps & product-expr]
   `(domonad parser-m ~steps ~...@product-expr))

The difference is the following. Without @:

=> (macroexpand-1 '(complex [...] foo bar baz))
(domonad parser-m [...] (foo bar baz))

With @:

=> (macroexpand-1 '(complex [...] foo bar baz))
(domonad parser-m [...] foo bar baz)


It's giving me this kind of error:
 Exception in thread "main" java.lang.ExceptionInInitializerError
(test_parse.clj:0)


Look at the stacktrace and scroll very far to the
end. Normally there is a "Caused by" sentence,
which probably is more informative. At least
that is my experience.

Hope this helps.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: Macro newbie: calling another macro

2009-04-30 Thread samppi

Thanks for the help. The problem was fixed when I both removed the ~
in front of parser-m and changed ~product-expr to ~...@product-expr.

Why is it, though, that parser-m should not be unquoted? If it was
unquoted, would it not just pass in the value of parser-m at macro-
expansion time?

On Apr 30, 8:47 am, Meikel Brandmeyer  wrote:
> Hi,
>
> Am 30.04.2009 um 17:39 schrieb samppi:
>
> >  (defmacro complex
> >    [steps & product-expr]
> >    `(domonad ~parser-m ~steps ~product-expr))
>
> Just leave out the ~ in front of parser-m. And
> I'm not sure how you want to handle product-expr.
> Maybe a @ is also missing here.
>
>   (defmacro complex
>     [steps & product-expr]
>     `(domonad parser-m ~steps ~...@product-expr))
>
> The difference is the following. Without @:
>
> => (macroexpand-1 '(complex [...] foo bar baz))
> (domonad parser-m [...] (foo bar baz))
>
> With @:
>
> => (macroexpand-1 '(complex [...] foo bar baz))
> (domonad parser-m [...] foo bar baz)
>
> > It's giving me this kind of error:
> >  Exception in thread "main" java.lang.ExceptionInInitializerError
> > (test_parse.clj:0)
>
> Look at the stacktrace and scroll very far to the
> end. Normally there is a "Caused by" sentence,
> which probably is more informative. At least
> that is my experience.
>
> Hope this helps.
>
> Sincerely
> Meikel
>
>  smime.p7s
> 5KViewDownload
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Metadata for Any Object

2009-04-30 Thread Mark Engelberg

On Thu, Apr 30, 2009 at 6:01 AM, Rich Hickey  wrote:
> Then, you need to know which operations require metadata propagation.
> That's built into the Clojure data structures but can't be retrofitted
> to arbitrary types.

Is there a list of which operations propagate metadata?  I know I've
been surprised a couple of times.  In particular, I have had trouble a
couple of times where I was using lists and was surprised that the
list operations did not propagate metadata.  I'd like to better
understand the overall plan of which do and do not.

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Dropping strings.

2009-04-30 Thread Nicolas Buduroi

> You can use (.substring s n), if n is larger than string length it
> will return a empty string.

Hum... that's not my experience, I'm at my job right now so I can't
double check this. Looking at the javadoc, it appears that if n is
larger than the string length it will throw an
IndexOutOfBoundsException. That must have been the reason why I've
written drop-str in the first place.

Thanks

- budu
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Metadata for Any Object

2009-04-30 Thread Rich Hickey



On Apr 30, 12:34 pm, Mark Engelberg  wrote:
> On Thu, Apr 30, 2009 at 6:01 AM, Rich Hickey  wrote:
> > Then, you need to know which operations require metadata propagation.
> > That's built into the Clojure data structures but can't be retrofitted
> > to arbitrary types.
>
> Is there a list of which operations propagate metadata?  I know I've
> been surprised a couple of times.  In particular, I have had trouble a
> couple of times where I was using lists and was surprised that the
> list operations did not propagate metadata.  I'd like to better
> understand the overall plan of which do and do not.

I don't want to revisit (yet again) the duality of lists as cells and
collections, but metadata propagates wherever it can without causing a
copy, i.e. you shouldn't be surprised that rest doesn't propagate
metadata.

However, there isn't a list, and metadata propagation could use an
audit. If there's a specific case where you think it should and it
doesn't please let me know.

Rich


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Macro newbie: calling another macro

2009-04-30 Thread Konrad Hinsen

On Apr 30, 2009, at 17:39, samppi wrote:

> I'm having trouble trying to create a macro that calls domonad with
> one argument already filled in: (domonad parser-m rest-of-arguments).
> parser-m is a monad defined in the same namespace. This is what I have
> right now:
>   (defmacro complex
> [steps & product-expr]
> `(domonad ~parser-m ~steps ~product-expr))

Unquote (the tilde) is used to insert the value of an expression into  
a template. That is fine for ~steps and ~product-expr. But ~parser-m  
would insert the *value* of parser-m, not the name itself. Try this  
instead:

   (defmacro complex
 [steps & product-expr]
 `(domonad parser-m ~steps ~product-expr))

Another variant is:

   (defmacro complex
 [steps & product-expr]
 `(domonad ~'parser-m ~steps ~product-expr))

The subtle difference is that ~'parser-m will insert an unqualified  
symbol into the template, whereas just parser-m will get you a  
namespace-qualified symbol that results of a namespace lookup of  
parser-m. In this particular case, you can use either, because the  
unqualified symbol you get from ~'parser-m will be expanded to a  
namespace-qualified symbol when the domonad macro is expanded.

Konrad.



--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Metadata for Any Object

2009-04-30 Thread Mark Engelberg

On Thu, Apr 30, 2009 at 9:46 AM, Rich Hickey  wrote:
> However, there isn't a list, and metadata propagation could use an
> audit. If there's a specific case where you think it should and it
> doesn't please let me know.

I think it just took me a while to figure out that cons does not
preserve metadata, but conj does.  Ditto with rest/pop.  I understand
why now, but I couldn't predict the behavior without experimentation.

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



What's the function that returns the opposite of a predicate?

2009-04-30 Thread samppi

I know there's a core function that takes a predicate and returns its
opposite:

(defn mystery [predicate]
  (fn [x] (not (predicate x

I'm having a lot of trouble finding the name of it in the docs,
though. Could anyone give me its name? Or does this function not exist
in the core?
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: What's the function that returns the opposite of a predicate?

2009-04-30 Thread Andrew Wagner
I think maybe you want complement: http://clojure.org/api#complement

On Thu, Apr 30, 2009 at 1:50 PM, samppi  wrote:

>
> I know there's a core function that takes a predicate and returns its
> opposite:
>
> (defn mystery [predicate]
>  (fn [x] (not (predicate x
>
> I'm having a lot of trouble finding the name of it in the docs,
> though. Could anyone give me its name? Or does this function not exist
> in the core?
> >
>

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: What's the function that returns the opposite of a predicate?

2009-04-30 Thread Parth Malwankar

On Thu, 30 Apr 2009 23:20:14 +0530, samppi  wrote:

>
> I know there's a core function that takes a predicate and returns its
> opposite:
>
> (defn mystery [predicate]
>   (fn [x] (not (predicate x
>
> I'm having a lot of trouble finding the name of it in the docs,
> though. Could anyone give me its name? Or does this function not exist
> in the core?

user=> (doc complement)
-
clojure.core/complement
([f])
   Takes a fn f and returns a fn that takes the same arguments as f,
   has the same effects, if any, and returns the opposite truth value.
nil
user=>

Regards,
Parth


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: What's the function that returns the opposite of a predicate?

2009-04-30 Thread Stephen C. Gilardi


On Apr 30, 2009, at 1:50 PM, samppi wrote:


I know there's a core function that takes a predicate and returns its
opposite:

(defn mystery [predicate]
(fn [x] (not (predicate x

I'm having a lot of trouble finding the name of it in the docs,
though. Could anyone give me its name? Or does this function not exist
in the core?



Is this the one you're thinking of?

user=> (find-doc "opposite")
-
clojure.core/complement
([f])
 Takes a fn f and returns a fn that takes the same arguments as f,
 has the same effects, if any, and returns the opposite truth value.
nil
user=>

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: What's the function that returns the opposite of a predicate?

2009-04-30 Thread samppi

Wonderful. I didn't think of searching for "opposite". Thanks
everyone.

On Apr 30, 11:25 am, "Stephen C. Gilardi"  wrote:
> On Apr 30, 2009, at 1:50 PM, samppi wrote:
>
> > I know there's a core function that takes a predicate and returns its
> > opposite:
>
> > (defn mystery [predicate]
> > (fn [x] (not (predicate x
>
> > I'm having a lot of trouble finding the name of it in the docs,
> > though. Could anyone give me its name? Or does this function not exist
> > in the core?
>
> Is this the one you're thinking of?
>
> user=> (find-doc "opposite")
> -
> clojure.core/complement
> ([f])
>   Takes a fn f and returns a fn that takes the same arguments as f,
>   has the same effects, if any, and returns the opposite truth value.
> nil
> user=>
>
> --Steve
>
>  smime.p7s
> 3KViewDownload
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Dropping strings.

2009-04-30 Thread Krešimir Šojat



> Hum... that's not my experience, I'm at my job right now so I can't
> double check this. Looking at the javadoc, it appears that if n is
> larger than the string length it will throw an
> IndexOutOfBoundsException. That must have been the reason why I've
> written drop-str in the first place.
>

You are right, I foolishly tested in only for n == l, sorry about that.
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: testing the reader...

2009-04-30 Thread Stephen C. Gilardi


On Apr 30, 2009, at 9:43 AM, Julien wrote:


-here's the clojure code:




(def text1 "testing thread")
(def T (proxy [Thread] []
 (run []
  (println "T thread : (eval (println text1))")
  (eval (println text1))

  (println "T thread : (eval (read-string \"(println  
text1)\"))")

  (eval (read-string "(println text1)"))
  )))

(println "Main thread : (eval (println text1))")
(eval (println text1))
(println "Main thread : (eval (read-string \"(println text1)\"))")
(eval (read-string "(println text1)"))
(. T start)


At any given time, within any given thread, the "current namespace" is  
bound to the var *ns*, a dynamic variable. Every thread has  
(potentially) an independent value for *ns*. If no call to "bind" has  
been made since the thread started, *ns* within that thread will be  
bound to its root binding which is the clojure.core namespace:


user=> (.getRoot (var *ns*))
#

Within the body of T:


- In the first eval, the expression (println text1) was compiled in  
the main thread while the user namespace was current. text1 was  
resolved at compile time to become user/text1.


The entire expression was resolved like this:

user=> `(eval (println text1))
(clojure.core/eval (clojure.core/println user/text1))

and the compiled.

When T ran, the current namespace was clojure.core, but the reference  
to text1 was fully qualified and referenced the intended var in user.  
Note that in this case "(clojure.core/println user/text1)" ran to  
completion while it was being evaluated as an argument to eval. What  
eval actually received was "nil". eval of nil produced nil.



- In the second eval, read-string produced a data structure that was  
passed to eval. eval tried to do its work by compiling the expression  
and running it. That compilation occurred within thread T where the  
current namespace was clojure.core. Since clojure.core/text1 doesn't  
exist, text1 could not be resolved and the compiler threw an exception.


You can "fix" the second eval either by changing \"(println text1)\"  
to \"(println user/text1)\" or by surrounding the body of T with a  
"binding" call that binds *ns* to user, or binds it to any namespace  
and then sets it with a call to "(in-ns 'user)".


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Book for Programming Clojure

2009-04-30 Thread Timothy Pratley

Hopefully this will give you some leads also:
http://en.wikibooks.org/w/index.php?title=Clojure_Programming/Further_Reading

Regards,
Tim.

On Apr 30, 7:49 pm, anderspe  wrote:
> First the "Programming Clojure" by   Stuart Halloway was sad to come
> April 2009, now i read
> Juni, so the loong wait have been longer. i know there is a PDF
> version, but i like to have a
> book.
>
> I am new to both Lisp and Clojure, but not to development.
>
> So is there an recommendation regarding books, tutorial etc to get
> into Clojure, without the
> book "Programming Clojure".
>
> Best regards
> Anders
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---