Re: Execute a string containing a form?

2010-04-22 Thread Mike Mazur
Hi, On Thu, Apr 22, 2010 at 20:17, Base basselh...@gmail.com wrote: say i have a string that contains a form: (+ 1 1) I want to actually execute this.  How do you do this?  I thought that eval would be able to handle this but apparently am misunderstanding what eval does. You need to read

Re: Execute a string containing a form?

2010-04-22 Thread Tassilo Horn
On Thursday 22 April 2010 14:17:15 Base wrote: Hi! say i have a string that contains a form: (+ 1 1) I want to actually execute this. How do you do this? I thought that eval would be able to handle this but apparently am misunderstanding what eval does. `eval' evals a form, so first

Re: Execute a string containing a form?

2010-04-22 Thread Douglas Philips
On 2010 Apr 22, at 8:17 AM, Base wrote: say i have a string that contains a form: (+ 1 1) I want to actually execute this. How do you do this? I thought that eval would be able to handle this but apparently am misunderstanding what eval does. Well, eval is the second half of what you want.

Re: Execute a string containing a form?

2010-04-22 Thread Base
Thank you all! I knew there was something simple that i was missing! On Apr 22, 7:28 am, Douglas Philips d...@mac.com wrote: On 2010 Apr 22, at 8:17 AM, Base wrote: say i have a string that contains a form: (+ 1 1) I want to actually execute this.  How do you do this?  I thought that

Re: Slides for short (45 minutes) presentation of clojure for java devs

2010-04-22 Thread Laurent PETIT
Oh, really no answer ? :'( 2010/4/21 Laurent PETIT laurent.pe...@gmail.com: Hello, I've consulted a lot of already made presentations of clojure. They are great, but I guess they may not suit my needs because it seems to me that either:  * they are more 1 1/2 to 2 hours talks than 45

Re: Slides for short (45 minutes) presentation of clojure for java devs

2010-04-22 Thread Joop Kiefte
I made one simple and short one for beginners, I think to your liking, but in Dutch... 2010/4/22 Laurent PETIT laurent.pe...@gmail.com Oh, really no answer ? :'( 2010/4/21 Laurent PETIT laurent.pe...@gmail.com: Hello, I've consulted a lot of already made presentations of clojure. They

Re: Slides for short (45 minutes) presentation of clojure for java devs

2010-04-22 Thread Laurent PETIT
2010/4/22 Joop Kiefte iko...@gmail.com: I made one simple and short one for beginners, I think to your liking, but in Dutch... too bad I don't speak Dutch :-( 2010/4/22 Laurent PETIT laurent.pe...@gmail.com Oh, really no answer ? :'( 2010/4/21 Laurent PETIT laurent.pe...@gmail.com:

Re: Slides for short (45 minutes) presentation of clojure for java devs

2010-04-22 Thread Laurent PETIT
Could I still take a look at it, to see the kind of examples you provided (are the source code examples in english ?) 2010/4/22 Laurent PETIT laurent.pe...@gmail.com: 2010/4/22 Joop Kiefte iko...@gmail.com: I made one simple and short one for beginners, I think to your liking, but in Dutch...

Re: Documentation (was: Re: duck-streams missing from clojure-contrib.jar file)

2010-04-22 Thread Alex Osborne
Douglas Philips d...@mac.com writes: Looking at the clojure.org front page, there is no roadmap link, or anything that seems to be like that, to know what is on the radar, There's no formal roadmap as such, most open-source projects just don't tend to work that way. Working notes and ideas

Re: Which version of Netbeans to use Compojure on OSX?

2010-04-22 Thread gary ng
I would choose the one with glassfish which includes the web app things that even though you may not need immediately(if compojure comes with embedded jetty) will be very likely in the future when you use other app containers(be it GAE or tomcat etc.) I picked the base Java SE version and needs

Re: Execute a string containing a form?

2010-04-22 Thread Heinz N. Gies
On Apr 22, 2010, at 14:28 , Douglas Philips wrote: eval can be a dangerous thing to use, you have to be very careful about where the source has come from, in terms of trusting that the code your programs 'eval's will not be malicious or dangerous in some way. There are no absolute rules

Re: duck-streams missing from clojure-contrib.jar file

2010-04-22 Thread Neal
Stu, Good book! It was pretty clear to me that it was a snapshot. It was really a user error on my part. Now that I have made that error, I won't make it again. Thanks, Neal On Apr 21, 9:31 am, Stuart Halloway stuart.hallo...@gmail.com wrote: The second level header tells you the branch

Re: duck-streams missing from clojure-contrib.jar file

2010-04-22 Thread Neal
Alex, Yes. I was using the snapshot. My bad. Neal On Apr 21, 8:11 am, Alex Osborne a...@meshy.org wrote: Hi Neal, Neal neal_degrego...@yahoo.com writes: I'm trying to use duck-streams, but it is missing from the clojure- contrib JAR file (at least in build #81).  I have listed the

Re: duck-streams missing from clojure-contrib.jar file

2010-04-22 Thread Neal
OK. Thanks everyone for your help. Neal On Apr 21, 8:11 am, Alex Osborne a...@meshy.org wrote: Hi Neal, Neal neal_degrego...@yahoo.com writes: I'm trying to use duck-streams, but it is missing from the clojure- contrib JAR file (at least in build #81).  I have listed the contents of

Re: Arguments for and et al

2010-04-22 Thread Bill Allen
I thought there might be a performance reason in there. Thanks for the pointer to clj-time. Looks like a huge improvement over java date/calendar. BTW: love the book. Mine is already getting dog eared. On Apr 21, 2010 8:24 AM, Stuart Halloway stuart.hallo...@gmail.com wrote: The built-in Java

Re: Missing fns: rotate rotate-while

2010-04-22 Thread Harvey Hirst
(defn rotate [n s]  (let [[front back] (split-at (mod n (count s)) s)]    (concat back front))) Don't forget (mod n 0) is an ArithmeticException. Harvey -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Reading from file

2010-04-22 Thread I.K.
Hi! I'm learning Clojure and trying some Google Code Jam exercises. I am more or less satisfied with the style of algorithms I write, but I would like to know how to do input/output. I want it to be Clojure style (terse/functional/efficient) not just rewriting the usual loops... Take a look at

Re: Missing fns: rotate rotate-while

2010-04-22 Thread Sean Devlin
Oh wow... totally would have :) On Apr 21, 8:16 pm, Harvey Hirst hhi...@gmail.com wrote: (defn rotate [n s]  (let [[front back] (split-at (mod n (count s)) s)]    (concat back front))) Don't forget (mod n 0) is an ArithmeticException. Harvey -- You received this message because you

Re: Reading from file

2010-04-22 Thread Per Vognsen
How about this? (use 'clojure.contrib.str-utils 'clojure.contrib.duck-streams) (defn parse [file] (let [r (reader file)] (map (fn [line] (map #(Integer/parseInt %) (.split line ))) (take (Integer/parseInt (.readLine r)) (repeatedly #(.readLine r)) (defn unparse [xss file]

Re: Reading from file

2010-04-22 Thread Sean Devlin
You'll want to take a look at the docs for c.c.string[1], so have that open in another tab. Anyway, let's assume you have the data in a file mytext.txt First, load the raw data with the slurp fn user=(def raw-string (slurp mytext.txt)) Next, you'll want to use the split-lines fn to create a

Re: Reading from file

2010-04-22 Thread Per Vognsen
I really hate how GMail line wraps without giving you a chance to preview before sending. Here's a version of parse that shouldn't line wrap. It also more closely parallels unparse by using for instead of map: (defn parse [file] (let [r (reader file)] (for [line (take (Integer/parseInt

Datatypes and Protocols update

2010-04-22 Thread Rich Hickey
I have been doing some work cleaning up the design and implementation of datatypes and protocols in preparation for the 1.2 release. Some notable changes for those who have been working with the earlier versions: deftype/reify now take an explicit 'this' argument in method sigs. The :as option is

Re: Datatypes and Protocols update

2010-04-22 Thread Mark Engelberg
I tried using deftype relatively recently, but realized it wouldn't work for my needs because serialization via *print-dup* wasn't yet implemented. I'd recommend including this with the 1.2 release (or is there a new recommended way to serialize Clojure data?) -- You received this message

reducing runtime errors due to mistyped keywords

2010-04-22 Thread Istvan Devai
Hi! In general, what to give greater attention if I'm getting lots of runtime errors due to mistyped keywords? (eg. I'm referencing a map where the keyword is non-existent and this nil value goes deep down into my code where it is very hard to see that this was caused by a non-existing map

Re: reducing runtime errors due to mistyped keywords

2010-04-22 Thread Jason Wolfe
Hi Istvan, I've run into this a fair bit too. To catch such problems (at runtime), I sprinkle my code with (safe-get m :key) in key places, rather than (:key m) or (m :key) or (get m :key). safe-get: (defmacro lazy-get Like get but lazy about evaluating default [m k d] `(if-let [pair#

Re: Datatypes and Protocols update

2010-04-22 Thread Konrad Hinsen
On 22.04.2010, at 18:53, Rich Hickey wrote: Feedback and errata welcome as always, One feature in the deftype/defrecord split that I regret is that defrecord no longer allows the redefinition of equals and hashCode. Any attempt to override those results in an error message about duplicate

Re: Datatypes and Protocols update

2010-04-22 Thread ataggart
On protocols: - doc string coming after the arg vecs seems odd. I'm used to putting them after the name of whatever I'm working on. On protocols doc: - You can implement a protocol on nil ... Object: could you elaborate on how these work and/or provide examples? I think this will solve the one

Re: Datatypes and Protocols update

2010-04-22 Thread Stuart Halloway
A good place to look for examples is protocols.clj and gvec.clj in clojure itself. protocols.clj includes an example of implementing a protocol on nil. Stu On protocols: - doc string coming after the arg vecs seems odd. I'm used to putting them after the name of whatever I'm working on.

Re: How to deal with clojure versions in libs

2010-04-22 Thread Heinz N. Gies
On Apr 19, 2010, at 7:52 , Heinz N. Gies wrote: Hi phil, thanks for the answer many good points there. So just to be sure, if I don't add a :gen-class (which I don't need to in my case) I can use the lib with both 1.1 and 1.2 w/o problems (save for the named ones) so the lein jar jar's

Re: Datatypes and Protocols update

2010-04-22 Thread Jason Wolfe
+1, I am also using this feature of the old deftype. On Apr 22, 12:15 pm, Konrad Hinsen konrad.hin...@fastmail.net wrote: On 22.04.2010, at 18:53, Rich Hickey wrote: Feedback and errata welcome as always, One feature in the deftype/defrecord split that I regret is that defrecord no longer

Re: Slides for short (45 minutes) presentation of clojure for java devs

2010-04-22 Thread Luc Préfontaine
Is there a Dutch version of Clojure ?!?!?! I want one in French then : (Laurent you just said you like to be bashed didn't you ? :))) Luc On Thu, 2010-04-22 at 15:09 +0200, Laurent PETIT wrote: Could I still take a look at it, to see the kind of examples you provided (are the source code

Re: Execute a string containing a form?

2010-04-22 Thread Luc Préfontaine
We store routing rules in a database as Clojure code and get these to be loaded dynamically and run according to some variable configuration. Of course we make sure the code forms are stringent in the database and we wrap execution of these things with proper error handling code :))) That's one

Re: Datatypes and Protocols update

2010-04-22 Thread ataggart
Ah, great! And of course the piece I as missing is that nil and Object get supported via extend. Makes sense now given that that was the section of the doc, but it didn't click the first time through. On Apr 22, 2:54 pm, Stuart Halloway stuart.hallo...@gmail.com wrote: A good place to look for

Re: Datatypes and Protocols update

2010-04-22 Thread MarkSwanson
Minor errata barely worth mentioning:on the page: http://clojure.org/datatypes employeee.getName() employeee needs just 2 'e' characters. Cheers. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Naming factory functions

2010-04-22 Thread joshua-choi
When it comes to naming factory functions—functions that create things— clojure.core gives four precedents: 1. Name it exactly what the new object is called. vector, hash-map, set. 2. Name it a shortened version of #1. vec. 3. Prefix #1 with make-. make-hierarchy, make-array. 4. Prefix #1 with