Re: Question about namespaces

2010-05-10 Thread Konrad Hinsen
On 9 May 2010, at 04:44, Mark Engelberg wrote: In Python, let's say I have a library "mylibrary.py", and from various files I say "from mylibrary import *". If I want to split mylibrary.py into two parts, say, library1.py and library2.py, then I can just change mylibrary.py to say: from library1

Re: macro help

2010-05-10 Thread RandyHudson
As Lauren Petit points out, you need the macro to define the whole desired result. Something like this should do it: (defmacro defautoroutes [name & paths] (let [getps (for [p paths] `(GET ~(str "/" p) (foo ~p)))] `(defroutes ~name ~...@getps))) (defautoroutes all-routes "one" "two" "three"

Re: Easier way to run Clojure from command line?

2010-05-10 Thread Jason Smith
Okay, so I use Java daily at work, and I am one of the local Maven experts. We use Eclipse, and I have been using CounterClockWise primarily for REPL. I'm not looking for an alternate way to run Clojure. I am not looking for an alternate build mechanism. I just think it would be more polished t

My First Clojure Program -- Can Someone Critique It?

2010-05-10 Thread Tim Morgan
I picked up Programming Clojure by Stuart Halloway last week and am working through the book. I'm coming from a Perl/Python/Ruby background, so Java + Lisp + functional programming is all new to me. I thought a good exercise would be to write a script that pings all ips on a subnet looking for exi

Re: Clojure Africa

2010-05-10 Thread Fabio Kaminski
Clojure Brasil is here: http://groups.google.com/group/clojure-br Im prototyping my startup this year, so it was a huge amount of effort trying to get into the right tecnology.. Clojure here is not so obvious, not even functional programming.. so a lot of work to make folks think "functionally" i

Re: Clojure Africa

2010-05-10 Thread Fabio Kaminski
oh.. another good reason to stick with it.. is that its a clear effort to make it right instead of make it popular, like object-functional pizza's out there that could only produce pizza software :) On Sun, May 9, 2010 at 6:03 PM, Fabio Kaminski wrote: > Clojure Brasil is here: http://groups.goog

Problems accessing records declared in a namespace in a REPL

2010-05-10 Thread Lee Hinman
I'm having a difficult time referencing a protocol in the user namespace, I have the following code: (ns clomoios.contextsearcher) (defprotocol Searcher (score [this term text] "Score this text in similarity") (rank [this term text] "Rank sentences in this text")) (defrecord ContextSearch

Re: API for posting multipart/form-data

2010-05-10 Thread Fabio Kaminski
i think a more "native"-wrapped approach (for a client only) is the http/*agent.clj* > agent-based asynchronous HTTP client and http/*connection.clj >* low-level HTTP client API around HttpURLConnection in the contrib package. On Mon, May 10, 2010 at 12:00 AM, Richard Newman wrote: > Anyone kn

Re: Easier way to run Clojure from command line?

2010-05-10 Thread Fabio Kaminski
1 - create a bat with the java -cp command.. int your PATH and in yor desktop.. hihihi 2 - if you use a ide like eclipse, intellij or netbeans.. theres a REPL there already.. 3 you could use emacs too, but since you are in a windows.. maybe thats not what you want.. with the ide or emacs, you coul

Re: macro help

2010-05-10 Thread James Reeves
On 7 May 2010 03:21, Micah Martin wrote: > I'm having trouble writing a macro and I hoping some one here can help.  My > desired result is the following: > > (defroutes all-routes >  (GET "/one"   (foo "one")) >  (GET "/two"   (foo "two")) >  (GET "/three" (foo "three"))) > > But I'd like to writ

clojure.contrib.shell broken with clojure commit 37d8f7a

2010-05-10 Thread Dave Jack
clojure.core/byte was modified a couple weeks ago as follows: (defn byte "Coerce to byte" {:tag Byte :inline (fn [x] `(. clojure.lang.RT (byteCast ~x)))} - [^Number x] (. x (byteValue))) + [^Number x] (clojure.lang.RT/byteCast x)) byteValue and byteCast behave differently with

Re: Problems accessing records declared in a namespace in a REPL

2010-05-10 Thread Stuart Halloway
Hi Lee, Your extend-protocol call is incorrectly parenthesized (rank is outside the body of the form). This means that "use" should blow up because the source is invalid. Maybe your use is reading a different source file than you think it is? Once I fixed that, the code works fine, at lea

Re: My First Clojure Program -- Can Someone Critique It?

2010-05-10 Thread Stuart Halloway
Hi Tim, Very readable -- a good first program! A few things you might do differently: (1) Keywords are fns. You don't have to say #(:exists %) -- just say :exists ! (2) You can apply the same trick as in #1 to #(not (:exists %)) by using remove instead of filter. (3) Similarly, #(:ip

Re: My First Clojure Program -- Can Someone Critique It?

2010-05-10 Thread patrik karlin
hello nott a expert my self but *#*(:ip %) == :ip and *#*(:exists %) == :exists witch seems more idiomatic 2010/5/9 Tim Morgan > I picked up Programming Clojure by Stuart Halloway last week and am > working through the book. I'm coming from a Perl/Python/Ruby > background, so Java + Lisp + func

My first clojure program - A swing app to display graphs

2010-05-10 Thread enjoying the view
Hi, Since everyone else seems to be getting such good advice from the pros on their first tries at Clojure, I thought I might as well take a chance and see what you guys have to say about my first try. It's a pretty simple application that I use to visually display graphs when I play with graph a

Re: My first clojure program - A swing app to display graphs

2010-05-10 Thread Meikel Brandmeyer
Hi, you don't have to do (into {} @reference). Dereferencing the reference will give you an immutable thing, which cannot change underneath your hands. You might want to look at clojure.contrib.swing-utils for little helpers like do-swing or add-action-listener and such. Sincerely Meikel -- Yo

Re: My First Clojure Program -- Can Someone Critique It?

2010-05-10 Thread Christophe Grand
Hello, In addition to Stuart's comments, I think your first+filter could be refactored in a call to "some" and that your map+filters could become fors. (defn get-subnet-from-args [args default] (or (some #(when (re-find #"^\d" %) %) args) default)) Or, you can rework your regex to match the wh

Re: Easier way to run Clojure from command line?

2010-05-10 Thread Fabio Kaminski
oops, sorry.. i read better your mail ...(not just the last replies :)) you're right.. Leiningen was correctly cited cause it has the automated bin scripts you wanted.. but even with a binary for that, will you ending , doing things manually, at least at first like putting clojure.jar in your jvm

Re: My First Clojure Program -- Can Someone Critique It?

2010-05-10 Thread Fabio Kaminski
in the following statement : "(4) Take a look at using futures instead of agents. " means futures are better than agents in all cases, or theres some particular cases? sorry about my laziness in not to hack the agents source.. but i thought it was better just to ask :) Thanks, Kaminski On Mon

Re: Problems accessing records declared in a namespace in a REPL

2010-05-10 Thread Lee Hinman
> it should have the correct amount of apologies. Err...what I meant to say was the correct amount of parentheses, not apologies. - Lee -- 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 Not

Re: My First Clojure Program -- Can Someone Critique It?

2010-05-10 Thread Tim Morgan
Stuart, thanks for your reply. Those are very helpful and constructive criticisms -- exactly what I was looking for. It only pings the ips once -- looking for existing hosts or non- existent hosts, depending on the arguments passed to the script. Coming from Ruby, using keywords (they resemble Ru

Re: Problems accessing records declared in a namespace in a REPL

2010-05-10 Thread Lee Hinman
On Mon, May 10, 2010 at 6:06 AM, Stuart Halloway wrote: > Hi Lee, > > Your extend-protocol call is incorrectly parenthesized (rank is outside the > body of the form). > > This means that "use" should blow up because the source is invalid. Maybe > your use is reading a different source file than yo

Re: My First Clojure Program -- Can Someone Critique It?

2010-05-10 Thread Tim Morgan
Thank you everyone for your critiques. This is exactly what I was hoping for. I must say my first Clojure experience (both with the language and the community) has been excellent. Stuart, your book is great. Worth every penny. Cheers. On May 10, 11:20 am, Christophe Grand wrote: > Hello, > > I

Re: My First Clojure Program -- Can Someone Critique It?

2010-05-10 Thread Laurent PETIT
2010/5/10 Fabio Kaminski : > in the following statement : > "(4) Take a look at using futures instead of agents. " > means futures are better than agents in all cases, or theres some particular > cases? In this particular case. Because *directly* using agents, which carry a bunch of "semantics" wi

agents returning nil by default

2010-05-10 Thread Anders Rune Jensen
Hello I've recently found out just what a good invention agents are. I find them to handle a few idioms I see in other languages very nicely. I started changing some of my code over to it, and it has really helped the structure. But I was a little surprised to find out that by default, if you don'

Re: My First Clojure Program -- Can Someone Critique It?

2010-05-10 Thread Tim Morgan
OK, I incorporated some of the suggestions mentioned here, including the idea of using futures instead of agents. Unfortunately, my script is now 3-4 times slower when using futures: http://gist.github.com/395153#file_pingdom_with_futures.clj I have a feeling it has something to do with the work

I wrote a tiny autotest tool in Clojure. Find the flaws!

2010-05-10 Thread Thomas Kjeldahl Nilsson
Hello, So I guess I'm piling onto the "please help a novice" threads here.. :) I've written a trivial autotest tool to make my feedback cycles as short as possible while learning and coding Clojure. I've only worked through Stuarts (excellent) book so far, so this is the first thing I'm writing m

How to use clojure-contrib library

2010-05-10 Thread Mat
Hi all, I am totally new to clojure and this is a very simple question, but I spent the last two hours trying to figure this out and I need help. I'm not able to use the clojure-contrib library and I am not able to find instructions here on this group and anywhere on the web. Maybe because this sh

Re: How to use clojure-contrib library

2010-05-10 Thread Luc Préfontaine
Hi, The trick is to get contrib on the class path of java so it can find the content of the library. The class path defines were Java will search for the components (classes in Java) to load while running. Clojure code is compiled on the fly and ends up as a being loaded as a Java class and may be

Re: My First Clojure Program -- Can Someone Critique It?

2010-05-10 Thread Christophe Grand
On Mon, May 10, 2010 at 10:18 PM, Tim Morgan wrote: > OK, I incorporated some of the suggestions mentioned here, including > the idea of using futures instead of agents. > > Unfortunately, my script is now 3-4 times slower when using futures: > http://gist.github.com/395153#file_pingdom_with_futu

Re: How to use clojure-contrib library

2010-05-10 Thread Michael Wood
On 11 May 2010 03:30, Luc Préfontaine wrote: > > Hi, > > The trick is to get contrib on the class path of java so it can find the > content of the library. > The class path defines were Java will search for the components (classes in > Java) to load while running. > Clojure code is compiled on t