Re: How to add extend print-method without screwing up ?

2010-01-06 Thread Meikel Brandmeyer
Hi,

On Jan 5, 11:14 pm, Gabi bugspy...@gmail.com wrote:

 This think could be solved easily if defmethod supported hierarchy as
 arg (or in meta).

This doesn't even solve your problem, since the hierarchy is used to
find out *which* method should be called. So hooking a hierarchy on a
method doesn't really help.

Sincerely
Meikel
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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

parsing/processing of big xml files...

2010-01-06 Thread Alex Ott
Hello all

I have question about processing big XML files with lazy-xml.  I'm trying to 
analyze
StackOverflow dumps with Clojure, and when analyzing 1.6Gb XML file with
posts, i get java stack overflow, although i provide enough memory for java
(1Gb of heap).

My code looks following way


(ns stackoverflow
  (:import java.io.File)
  (:use clojure.contrib.lazy-xml))

(def so-base /data-sets/stack-overflow/2009-12/122009 SO)

(def posts-file (File. (str so-base /posts.xml)))

(defn count-post-entries [xml]
  (loop [counter 0
 lst xml]
(if (nil? lst)
  counter
  (let [elem (first lst)
rst (rest lst)]
(if (and (= (:type elem) :start-element) (= (:name elem) :row))
  (recur (+ 1 counter) rst)
  (recur counter rst))

and run it with 

(stackoverflow/count-post-entries (clojure.contrib.lazy-xml/parse-seq 
stackoverflow/posts-file))

I don't collect real data here, so i expect, that clojure will discard
already processed data.

The same problem with stack overflow happens, when i use reduce:

(reduce (fn [counter elem]
  (if (and (= (:type elem) :start-element) (= (:name elem) :row))
(+ 1 counter)
counter))
0 (clojure.contrib.lazy-xml/parse-seq stackoverflow/posts-file))

So, question is open - how to process big xml files in constant space? (if
I won't collect much data during processing)

-- 
With best wishes, Alex Ott, MBA
http://alexott.blogspot.com/   http://xtalk.msk.su/~ott/
http://alexott-ru.blogspot.com/
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To 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

peepcode screencasts

2010-01-06 Thread Konrad Scorciapino
Hey guys, 

I think it is worth convincing peepcode to develop more Clojure
screencasts, like this awesome one[1] from Phil Hagelberg. If you have
some time, please show them your enthusiasm by voting up here:

http://suggestions.peepcode.com/pages/15-general/suggestions/349533-more-lisp-clojure-screencasts-?ref=title

Thanks!

[1]: http://peepcode.com/products/functional-programming-with-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 posts from new members are moderated - please be patient with your 
first post.
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: peepcode screencasts

2010-01-06 Thread Jeff Heon
I would add the suggestion to buy the current screencast, as it is
excellent and would go an extra mile than the vote 8)

PS. I just loved the grue reference 8)
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To 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: Having difficulties with compilation in slime, emacs and clojure-project

2010-01-06 Thread Phil Hagelberg
Rob Lachlan robertlach...@gmail.com writes:

 I have src and test in the directory I'm passing in.  The problem
 however, seems to be on the emacs end.  In the mini-buffer when I
 enter in Project root: path-to-project and press return, the cursor
 just moves to the next line in the mini- buffer.  So I think that the
 clojure-project function is getting stuck right at that spot.

That's a bug that was fixed many months ago; sounds like you need to
update your version of swank-clojure:

http://github.com/technomancy/swank-clojure

Installation is handled through Emacs' package manager:

http://tromey.com/elpa/install.html

-Phil
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To 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: Leiningen uberjar: excluding dev-dependencies; new minus-clojure task

2010-01-06 Thread Perry Trolard


On Jan 2, 12:35 am, Phil Hagelberg p...@hagelb.org wrote:

 I'm a little reluctant to make calculating the classpath any more
 complicated than it currently is since that logic needs to be duplicated
 in a few places, but I agree that the current situation is not great.

 Another idea would be to write a hidden blacklist file when fetching the
 dev dependencies. The uberjar could then check that to know which jars
 to skip.

 I'm not sure which approach I prefer... thoughts?

I thought about the latter, too. I don't currently understand the
maven stuff enough to know how dependencies get resolved into actual
jarfile names enough to do this (there's the DependenciesTask c.
business in leiningen/deps.clj), but I'd be happy to investigate, esp.
if someone were willing to point me in the right direction.

  I was working on uberjar because I want to write a similar task as a
  plugin, which is an uberjar without clojure  clojure-contrib
  included, so that I can drop a project  its dependencies in my local
  Clojure development environment, e.g. my Clojure saxon wrapper library
  as well as the Java Saxon jars it depends on. Anyone else have this
  use case?

 I'm not sure I understand. Why don't you just open your saxon wrapper
 project in your IDE directly rather than adding an uberjar generated
 from it? Plus if you put clojure and contrib on the classpath before
 youruberjar, then the versions in your uberjar will be shadowed.

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 put clojure 
clojure-contrib on the classpath, so I simply want the Clojure library
 any of its dependencies zipped up in a sort of uberjar-minus-clojure
(to avoid shadowing, as you mention).

I suppose I could create a leiningen project for my clj script,
specifying libraries I want as dependencies  then just putting its
uberjar on the classpath, but this requires that the libraries are
available in maven repos. Have other leiningen users solved this?

Thanks,
Perry
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To 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: parsing/processing of big xml files...

2010-01-06 Thread Graham Fawcett
Hi Alex,

On Wed, Jan 6, 2010 at 9:06 AM, Alex Ott alex...@gmail.com wrote:
 Hello all

 I have question about processing big XML files with lazy-xml.  I'm trying to 
 analyze
 StackOverflow dumps with Clojure, and when analyzing 1.6Gb XML file with
 posts, i get java stack overflow, although i provide enough memory for java
 (1Gb of heap).

Someone asked this question a while back, and a suggestion given was
to use Mark Triggs' XOM wrapper:

http://github.com/marktriggs/xml-picker-seq

Thread:
http://groups.google.com/group/clojure/browse_thread/thread/365ca7aaaf8d55b7?pli=1

Cheers,
Graham


 My code looks following way


 (ns stackoverflow
  (:import java.io.File)
  (:use clojure.contrib.lazy-xml))

 (def so-base /data-sets/stack-overflow/2009-12/122009 SO)

 (def posts-file (File. (str so-base /posts.xml)))

 (defn count-post-entries [xml]
  (loop [counter 0
         lst xml]
    (if (nil? lst)
      counter
      (let [elem (first lst)
            rst (rest lst)]
        (if (and (= (:type elem) :start-element) (= (:name elem) :row))
          (recur (+ 1 counter) rst)
          (recur counter rst))

 and run it with

 (stackoverflow/count-post-entries (clojure.contrib.lazy-xml/parse-seq 
 stackoverflow/posts-file))

 I don't collect real data here, so i expect, that clojure will discard
 already processed data.

 The same problem with stack overflow happens, when i use reduce:

 (reduce (fn [counter elem]
          (if (and (= (:type elem) :start-element) (= (:name elem) :row))
            (+ 1 counter)
            counter))
        0 (clojure.contrib.lazy-xml/parse-seq stackoverflow/posts-file))

 So, question is open - how to process big xml files in constant space? (if
 I won't collect much data during processing)

 --
 With best wishes, Alex Ott, MBA
 http://alexott.blogspot.com/           http://xtalk.msk.su/~ott/
 http://alexott-ru.blogspot.com/

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To 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

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To 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

ClassCastException from RT.java in Day Communique

2010-01-06 Thread Warren Wood
The cast in the following method from RT.java throws a
ClassCastException when trying to compile Clojure within the Day
Communique 4.2.1 content management system.  Any suggestions?

thanks,

Warren

static public long lastModified(URL url, String libfile) throws
Exception{
if(url.getProtocol().equals(jar)) {
return ((JarURLConnection) url.openConnection()).getJarFile().getEntry
(libfile).getTime();
}
else {
return url.openConnection().getLastModified();
}
}
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To 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: ClassCastException from RT.java in Day Communique

2010-01-06 Thread Warren Wood
Here is what the exception says :

Caused by: java.lang.RuntimeException: java.lang.ClassCastException:
com.day.cq.net.jar.ContentBusJarURLConnection cannot be cast to
java.net.JarURLConnection at clojure.lang.RT.clinit(RT.java:291)

On Jan 6, 3:11 pm, Warren Wood warrenthomasw...@yahoo.com wrote:
 The cast in the following method from RT.java throws a
 ClassCastException when trying to compile Clojure within the Day
 Communique 4.2.1 content management system.  Any suggestions?

 thanks,

 Warren

 static public long lastModified(URL url, String libfile) throws
 Exception{
 if(url.getProtocol().equals(jar)) {
 return ((JarURLConnection) url.openConnection()).getJarFile().getEntry
 (libfile).getTime();}

 else {
 return url.openConnection().getLastModified();

 }
 }


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To 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: Understanding the continuation monad's bind operator

2010-01-06 Thread Steven E. Harris
Konrad Hinsen konrad.hin...@fastmail.net writes:

 Exactly. The result of m-bind must be a continuation-accepting  
 function again.

Yes, and invoking 'mv' yields such a function.

 That's the role of the outer layer (fn [c] ...).

That one adds /another/ layer, but the inner function returned by 'mv'
has the same signature, right?

 It is indeed a value of the right type, but it is not right value that  
 represents the composite computation.

Ah, now we're getting somewhere.

 This version of m-bind would not return the composite computation, but  
 rather execute it immediately. This is best seen by the position of  
 mv. In your m-bind, mv is called when m-bind is called. That's not the  
 desired behaviour.

I'm interested in what you mean by composite computation, because I
think it's hinting at some concept for monads that I missed. If, as you
say, executing the function immediately is not acceptable behavior, then
I infer that the goal is to delay evaluation of the monadic function 'f'
until someone finally passes in a real continuation as, say, by the
`run-cont' function. Is that right?

If so, is it the case with all or most monads that the bind operator is
not meant to actually perform computation on the spot, but rather to
compose a delayed computation, or is this delaying particular to the
continuation monad?

-- 
Steven E. Harris

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To 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: Understanding the continuation monad's bind operator

2010-01-06 Thread Steven E. Harris
jim jim.d...@gmail.com writes:

 Don't know if you saw, but I did a whole tutorial on the continuation
 monad.

Your essay is how I got started with monads in Clojure. I've read it six
times now (along with five other of your essays on the subject), but
perhaps I missed the requirement pertaining to delaying evaluation of
the monadic function provided to bind.

-- 
Steven E. Harris

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To 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: Understanding the continuation monad's bind operator

2010-01-06 Thread Steven E. Harris
I have a few more questions concerning how one interacts with a
continuation monad. It's clear that a monadic function accepts some
base value and returns a monadic value, in turn being a function
accepting a single continuation argument.

That means that a monadic function has a signature like

  a - m b

Say that we're looking to use some normal functions with this
monad. Those functions may have signatures like

  a - b

They clearly don't return the right kind of value. There must be some
way to integrate such functions without writing new wrappers around them
by hand. Is this a job for `m-fmap'? Reading the implementation, it
looks like it would take a normal function and allow it to call on the
basic value extracted from a monadic value.

The lift operator also sounded relevant, but, if I understand it
correctly, it converts a normal function to one that accepts a monadic
value and returns a monadic value. That's the wrong argument type to be
used with bind -- which wants to call on a monadic function with a basic
value -- so I don't understand when one would want to use lift. When
would one be able to call on a lifted function? A simple example would
help.

-- 
Steven E. Harris

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To 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

ANN: 6pm Sat, Dec 9th: Wraith Scheme, Paralell Distributed Clojure at the Hacker Dojo

2010-01-06 Thread nallen05
Two very cool presentations this Saturday at the Hacker Dojo in
Mountain View:

1. An introduction to Wraith Scheme by Jay Reynolds Freeman
2. An introduction to parallel and distributed programming with
Clojure by Amit Rathore

Go here for more info: http://www.meetup.com/balisp/calendar/12248048/

Hope to see you there!

Nick
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To 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: Having difficulties with compilation in slime, emacs and clojure-project

2010-01-06 Thread Rob Lachlan
Thanks for the help.  I had initially installed slime, clojure-mode
and swank following the instructions at 
http://riddell.us/tutorial/slime_swank/slime_swank.html

I tried simply installing swank-clojure, but that seemed to conflict
with what I already had.  So I removed everything -- slime, clojure-
mode, etc.  and installed swank-clojure using ELPA.

This in turn installed slime, slime-repl, swank-clojure, and clojure-
mode.  But now when I try M-x slime, I get:

Searching for program: no such file or directory, lisp

Clearly, my emacs-fu is not strong enough.  Any ideas?

On Jan 6, 9:32 am, Phil Hagelberg p...@hagelb.org wrote:
 Rob Lachlan robertlach...@gmail.com writes:
  I have src and test in the directory I'm passing in.  The problem
  however, seems to be on the emacs end.  In the mini-buffer when I
  enter in Project root: path-to-project and press return, the cursor
  just moves to the next line in the mini- buffer.  So I think that the
  clojure-project function is getting stuck right at that spot.

 That's a bug that was fixed many months ago; sounds like you need to
 update your version of swank-clojure:

 http://github.com/technomancy/swank-clojure

 Installation is handled through Emacs' package manager:

 http://tromey.com/elpa/install.html

 -Phil
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To 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: ANN: 6pm Sat, Dec 9th: Wraith Scheme, Paralell Distributed Clojure at the Hacker Dojo

2010-01-06 Thread ajay gopalakrishnan
It's Jan 9 I guess

On Wed, Jan 6, 2010 at 10:53 PM, nallen05 nalle...@gmail.com wrote:

 Two very cool presentations this Saturday at the Hacker Dojo in
 Mountain View:

 1. An introduction to Wraith Scheme by Jay Reynolds Freeman
 2. An introduction to parallel and distributed programming with
 Clojure by Amit Rathore

 Go here for more info: http://www.meetup.com/balisp/calendar/12248048/

 Hope to see you there!

 Nick

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To 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