Re: idiomatic Clojure for agents?

2008-10-27 Thread Chouser
On Mon, Oct 27, 2008 at 10:06 PM, Stuart Halloway <[EMAIL PROTECTED]> wrote: > > The code below implements a Monte Carlo simulation to estimate the > value of pi. It works, and it was easy to reuse the original single- > threaded approach across multiple agents. > > How idiomatic is this use of ag

Suggest fcase variant "pred-case"

2008-10-27 Thread Stephen C. Gilardi
I used Stuart Sierra's 'fcase' contrib today to good effect. Nice job, Stuart! I have an idea for another fcase variant that I think is useful: (defmacro pred-case "Case where test values are predicates to be applied to the test value." [test-value & clauses] `(fcase (fn [pred# value

idiomatic Clojure for agents?

2008-10-27 Thread Stuart Halloway
Hi all, The code below implements a Monte Carlo simulation to estimate the value of pi. It works, and it was easy to reuse the original single- threaded approach across multiple agents. How idiomatic is this use of agents? Other than bringing in ForkJoin, are there other idiomatic ways to p

Re: Idiomatic Clojure code?

2008-10-27 Thread Bill Clementson
On Mon, Oct 27, 2008 at 4:06 PM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > > > On Oct 27, 3:15 pm, "Bill Clementson" <[EMAIL PROTECTED]> wrote: >> On Mon, Oct 27, 2008 at 11:31 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: >> >> > On Oct 27, 12:04 pm, "Bill Clementson" <[EMAIL PROTECTED]> wrote: >>

Re: Idiomatic Clojure code?

2008-10-27 Thread Rich Hickey
On Oct 27, 3:15 pm, "Bill Clementson" <[EMAIL PROTECTED]> wrote: > On Mon, Oct 27, 2008 at 11:31 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > > On Oct 27, 12:04 pm, "Bill Clementson" <[EMAIL PROTECTED]> wrote: > >> Hi Chouser > > >> On Mon, Oct 27, 2008 at 8:46 AM, Chouser <[EMAIL PROTECTED]>

Re: Evaluation of arguments in a macro

2008-10-27 Thread Matt Moriarity
well :title and :visible are not the only ones i want to support, i would like something that would work with any keyword and convert it to the right setter. you are right about the need for a let. i've been away from lisp for a while, and i forgot about this sort of thing. but will a let fix my

Re: interactive 2D plotting

2008-10-27 Thread lispy
Okay... here's my first attempt at Clojure code: make "units" that know how to draw themselves: (defmulti poly :Unit) (defn unit [name x y] {:Unit :Piece :name name :x x :y y}) (defmethod poly :Piece [p] (let [x (:x p) y (:y p)] (list x,y (+ x 200),y (+ x 200),(+ y 200) x,(+ y

Re: Evaluation of arguments in a macro

2008-10-27 Thread mb
Hi, On 27 Okt., 21:08, Matt Moriarity <[EMAIL PROTECTED]> wrote: > I am trying to write a macro to rewrite something like this: > > (set-props my-jframe :title "blah" :visible true) > > Into calls to the setter methods. I finally settled on this: > > (defmacro set-props [obj & props] > (l

Re: Idiomatic Clojure code?

2008-10-27 Thread Rich Hickey
On Oct 27, 12:04 pm, "Bill Clementson" <[EMAIL PROTECTED]> wrote: > Hi Chouser > > On Mon, Oct 27, 2008 at 8:46 AM, Chouser <[EMAIL PROTECTED]> wrote: > > > I think it's generally better to use = instead of .equals for > > equality, unless you have a specific reason to not use = (which I > > don

Patch: better exception from Script when user.clj is broken.

2008-10-27 Thread wwmorgan
I was in the process of porting our clojure code base to work with SVN head when I came across the following behavior. It turns out that the upgrade to head broke our user.clj. If user.clj is broken, and you invoke clojure.lang.Script from the command line (or from an ant build process, or you res

Re: Modified doto

2008-10-27 Thread mac
On Oct 25, 10:27 am, "V.Quixote" <[EMAIL PROTECTED]> wrote: > I'd like some version of doto that works on bare Classes (defmacro sdoto "Version of doto for use with static methods" [x & methods] `(do ~@(map (fn [m] (list '. x m)) methods) ~x)) Here you go. sdoto for

Move user.clj out of default package?

2008-10-27 Thread Chas Emerick
I'd like to suggest that clojure no longer look for a user.clj in the default package (/user.clj). The user.clj file is a handy hook for init-time code, but it's position causes the NetBeans application framework (by default) to not load it at all, and to emit a pretty ugly stack trace (which I'v

Evaluation of arguments in a macro

2008-10-27 Thread Matt Moriarity
I am trying to write a macro to rewrite something like this: (set-props my-jframe :title "blah" :visible true) Into calls to the setter methods. I finally settled on this: (defmacro set-props [obj & props] (let [prop-map (apply hash-map props)] `(do ~(for [[key val] prop-

Re: Idiomatic Clojure code?

2008-10-27 Thread Bill Clementson
On Mon, Oct 27, 2008 at 11:31 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > > > On Oct 27, 12:04 pm, "Bill Clementson" <[EMAIL PROTECTED]> wrote: >> Hi Chouser >> >> On Mon, Oct 27, 2008 at 8:46 AM, Chouser <[EMAIL PROTECTED]> wrote: >> >> > I think it's generally better to use = instead of .equa

Re: Special forms and namespaces

2008-10-27 Thread Stephen Wrobleski
On Mon, Oct 27, 2008 at 07:58:09AM -0700, Tayssir John Gabbour wrote: > Pretty cool; this means that special operators just shadow my attempts > to redefine them. For example: > > user> (defn quote [a b] > (+ a b)) > #'user/quote > user> (quote 1 2) ;; Quote ignores args after the first..

Re: re-def stuff

2008-10-27 Thread Krukow
On Oct 27, 12:50 pm, Rich Hickey <[EMAIL PROTECTED]> wrote: > A var's root has volatile (overwrite, last one in wins) semantics. > That means that anyone can change it and everyone will see the > changes. You *can* re-def a fn being used by a long running loop: Thanks for the clarification, Ric

Re: LazyMap and why Delegation is powerful

2008-10-27 Thread Phil Jordan
Meikel Brandmeyer wrote: > Am 25.10.2008 um 15:49 schrieb Phil Jordan: >> I tried both the release jar and building my own from hg (by the way, >> your Makefile fails on GNU Make on Linux, as far as I can tell it's >> because you're using .for) and they suffer from the same problem. > Obviously th

Re: Idiomatic Clojure code?

2008-10-27 Thread Chouser
On Mon, Oct 27, 2008 at 12:25 PM, Stuart Halloway <[EMAIL PROTECTED]> wrote: > > I think I am missing something here, can you elaborate? > >> By the way, difference is eager, so I'm not sure there's much point in >> using lazy-cat. :-) > > I am using lazy-cat *because* difference is eager. Is that

Re: Idiomatic Clojure code?

2008-10-27 Thread Stuart Halloway
Chouser, I think I am missing something here, can you elaborate? > By the way, difference is eager, so I'm not sure there's much point in > using lazy-cat. :-) I am using lazy-cat *because* difference is eager. Is that mistaken? For example, the first expression below returns immediately, and

Re: Idiomatic Clojure code?

2008-10-27 Thread Bill Clementson
Hi Chouser On Mon, Oct 27, 2008 at 8:46 AM, Chouser <[EMAIL PROTECTED]> wrote: > > I think it's generally better to use = instead of .equals for > equality, unless you have a specific reason to not use = (which I > don't think is the case here). Only that it allowed me to talk about Java interop

Re: Idiomatic Clojure code?

2008-10-27 Thread Chouser
I think it's generally better to use = instead of .equals for equality, unless you have a specific reason to not use = (which I don't think is the case here). On Mon, Oct 27, 2008 at 11:12 AM, Stuart Halloway <[EMAIL PROTECTED]> wrote: > > You could do something like this: > > (defn seq-xor-2-seq

Re: interactive 2D plotting

2008-10-27 Thread lispy
I installed Java 1.6 and the 3D library. This code runs-- nifty! I tried running interactively like you say below, but entering (clean) at the REPL crashes it. Wait... tried it again and it worked fine. This is really cool! (Brings back memories of my Atari 800.) Timothy Pratley wrote: > sou

Re: Idiomatic Clojure code?

2008-10-27 Thread Bill Clementson
Hi Stuart, Thanks, that's a nice alternative approach! Bill On Mon, Oct 27, 2008 at 8:12 AM, Stuart Halloway <[EMAIL PROTECTED]> wrote: > > Hi Bill, > > You could do something like this: > > (defn seq-xor-2-seqs > "Returns the unique values that are in one sequence but not the > other." > [

Re: Idiomatic Clojure code?

2008-10-27 Thread Stuart Halloway
Hi Bill, You could do something like this: (defn seq-xor-2-seqs "Returns the unique values that are in one sequence but not the other." [x y] (let [x (into #{} x) y (into #{} y)] (lazy-cat (clojure.set/difference x y) (clojure.set/difference y x Not sur

Re: Special forms and namespaces

2008-10-27 Thread Tayssir John Gabbour
Stephen C. Gilardi wrote: > Yes, that's one of the things that's special about them. They are > resolved as special forms independent of the current namespace. > > I'm not sure if it's essential or a design choice that they have no > namespace of their own. Pretty cool; this means that special op

IntelliJ Plugin

2008-10-27 Thread opus111
Hello all, I am new to this group, so forgive me if this is an old question. Is anyone working on a Clojure plugin for IntelliJ? Thanks Peter --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To pos

Idiomatic Clojure code?

2008-10-27 Thread bc
Hi all, I've put on my blog (http://bc.tech.coop/blog/081027.html) a post about some Clojure language features. In the post, I point out the features in a couple of functions that I wrote (which do an "exclusive or (XOR)" on sequences). Since I'm new to Clojure and still learning how to do things

Re: RFC: ClojureCheck

2008-10-27 Thread Stuart Halloway
Hi Bill, Agreed, at least in part. I think that a good test suite for a language like Clojure should include both fixed values and generated ones. I just wanted both APIs to be available at the beginning so that volunteers could pick the most appropriate choice for a particular test. Stuar

Re: Special forms and namespaces

2008-10-27 Thread Stephen C. Gilardi
On Oct 27, 2008, at 10:15 AM, Tayssir John Gabbour wrote: > Hi, > > I've noticed that symbols naming special forms don't belong to a > namespace. For example: > > user> (map #'namespace [`def `do `if `quote `assoc]) > (nil nil nil nil "clojure") > > Is this expected? Yes, that's one of the thing

Special forms and namespaces

2008-10-27 Thread Tayssir John Gabbour
Hi, I've noticed that symbols naming special forms don't belong to a namespace. For example: user> (map #'namespace [`def `do `if `quote `assoc]) (nil nil nil nil "clojure") Is this expected? Thanks! Tayssir --~--~-~--~~~---~--~~ You received this message beca

Re: java interop question

2008-10-27 Thread Phil Jordan
notallama wrote: > this may be more of a java question than a clojure question. i dunno. > > how do i use a java class from clojure? > > it's easy enough if it's one of the default java libraries, but so far > all i have managed with classes i wrote is "unable to resolve to > classname" > > i t

Re: Recent breakage (regression?) of macros

2008-10-27 Thread Phil Jordan
Hi Rich, Thanks for the quick reply! I'm probably just being slow here, for which I apologise, but some questions remain: Rich Hickey wrote: > On Oct 26, 3:49 pm, Phil Jordan <[EMAIL PROTECTED]> wrote: >> First of all, is the breakage intentional? > > Yes. You can no longer embed unreadable obj

Re: Clojure ant target version

2008-10-27 Thread Rich Hickey
On Oct 26, 11:16 am, James Reeves <[EMAIL PROTECTED]> wrote: > When you build Clojure from SVN using the ant file, it defaults to > compiling the class files for the highest version of Java available on > your system. So if you have Java 1.6, the clojure.jar file you make > will be inaccessible

Re: re-def stuff

2008-10-27 Thread Rich Hickey
On Oct 26, 10:37 am, Krukow <[EMAIL PROTECTED]> wrote: > On Oct 26, 1:48 pm, "Matti Jagula" <[EMAIL PROTECTED]> wrote: > > > On Sat, Oct 25, 2008 at 3:19 PM, Krukow <[EMAIL PROTECTED]> wrote: > > > I am kind of embarrassed to ask this, but is there a "correct way" to > > > do this . Do you simpl

java interop question

2008-10-27 Thread notallama
this may be more of a java question than a clojure question. i dunno. how do i use a java class from clojure? it's easy enough if it's one of the default java libraries, but so far all i have managed with classes i wrote is "unable to resolve to classname" i tried running the repl from the dire

Re: Ideal Hash Trees (Bagwell paper)

2008-10-27 Thread Raul Hernandez
Hi again, I answer myself as this is explained in that very paper: ... 3.1 Search for a key ... A small, but important implementation consideration is the identification of sub- tries or key/value nodes by a bit flag in the data structure. Using C+ + the bit uses the least significant bit of the