Re: Curious about Cells

2009-02-10 Thread Raffael Cavallaro
On Feb 9, 5:00 pm, Stuart Sierra wrote: > > My latest implementation, at clojure.contrib.auto-agents, does *not* > handle circular dependencies.  It uses Agents and Watchers to > implement the updates. from auto-agent.clj: (defmacro auto-agent "Creates an agent whose value is the result of

Re: Curious about Cells

2009-02-10 Thread Raffael Cavallaro
On Feb 10, 12:34 pm, Krešimir Šojat wrote: > > this errors on loading. Should that be "add-watch" instead? > > In revision 1194 add-watch was renamed to add-watcher. > > -- > Krešimir Šojat Ah, ok, the API docs don't reflect this. --~--~-~--~~~---~--~~ You recei

Re: Libraries? model and generic-functions

2009-02-17 Thread Raffael Cavallaro
On Feb 17, 9:56 am, mikel wrote: > I'll let the level of interest > guide me in whether I package them for more general distribution. I am very interested in both of these subsystems and would love to see you package them as clojure.contrib libraries. Hopefully others feel the same and we'

Re: arguments to dissoc and select-keys

2009-02-21 Thread Raffael Cavallaro
On Feb 21, 6:47 pm, Mark Volkmann wrote: > I have to wrap the keys in a collection like this instead. > > (select-keys popsicle-map [:red :green :blue]) of course if you're doing this much: user=> (defmacro take-keys [some-map & keys+] `(select-keys ~some-map ~(vec keys+))) #'user/

Re: generic functions update

2009-02-21 Thread Raffael Cavallaro
count me as very interested too. regards, Ralph --~--~-~--~~~---~--~~ 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 ema

Re: dotimes suggestion

2009-02-22 Thread Raffael Cavallaro
On Feb 22, 2:54 pm, Mirko wrote: > > In lisp you would define it as (untested): > > (defmacro print-times (reps text) > `(do-times (i ,reps) > (print ,text)) > > (Not trying to force-feed lisp, just that I do not know the closure > syntax). user=> (defmacro repeat-times [n & body]

Re: challenge: best fibo implementation under the new laziness?

2009-02-23 Thread Raffael Cavallaro
On Feb 23, 2:51 pm, "Stephen C. Gilardi" wrote: > The fibs implementation in clojure.contrib.lazy-seqs is not a function   > that returns fib(n) given n. > I think defining a fib(n) function somewhere in contrib or core that   > operates as efficiently as we can manage would be a good idea.

Re: challenge: best fibo implementation under the new laziness?

2009-02-23 Thread Raffael Cavallaro
On Feb 23, 9:31 pm, Jeffrey Straszheim wrote: > The speed of the JVM's big ints, and therefore Clojure's, doesn't seem to be > competitive. Clearly the JVM's big ints doesn't compare favorably with GMP. On the other hand, Clojure falls near the middle of the range of the various lisps and sche

Re: challenge: best fibo implementation under the new laziness?

2009-02-24 Thread Raffael Cavallaro
On Feb 24, 4:14 am, "Dimiter \"malkia\" Stanev" wrote: > And this is by using "java -server", not "java -client", right? yes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, se

Re: challenge: best fibo implementation under the new laziness?

2009-02-24 Thread Raffael Cavallaro
On Feb 24, 1:18 pm, Luke VanderHart wrote: > Just out of curiosity - did you by any chance "warm up" the JVM to > make sure that the fib function was JIT'd before you did this > benchmark? > > On Feb 23, 5:46 pm, Raffael Cavallaro > wrote: > > for

Re: So what do we want for a Cells-alike ?

2009-03-02 Thread Raffael Cavallaro
On Mar 2, 10:41 pm, Jeffrey Straszheim wrote: > First off, Clojure is not Common Lisp (to say the least), so I don't think > we necessarily need to create as stateful a library as the original Cells. > I've used Cells-like architectures before in GUI apps (although not as a > separate abstract

Re: So what do we want for a Cells-alike ?

2009-03-03 Thread Raffael Cavallaro
On Mar 3, 8:04 am, Rich Hickey wrote: > If B and C depend on A in such > a way that their values must be coordinated in order to be valid and > consistent, then maybe they shouldn't independently depend on A, > instead a transaction should fire on changes to A, which in turn > updates B and C

Re: So what do we want for a Cells-alike ?

2009-03-03 Thread Raffael Cavallaro
On Mar 3, 10:45 am, Anand Patil wrote: > Cells don't update until all of their parents have reported in, ie > reached the current step. This bit is important (i.e., no update until all parents are current) and constitutes an implicit notion of current step. It still doesn't get you time lags

Re: Game of Life

2009-03-04 Thread Raffael Cavallaro
In my experience, life is a bit more interesting if the field wraps and it is square. Here are some mods to your most recent version that does this. I've also parameterized the field size, the delay, and the initial probability of a cell being occupied. Thanks for sharing this - it's fun. ((imp

Re: Clojure infinite loop

2009-03-06 Thread Raffael Cavallaro
On Mar 6, 5:58 pm, Chouser wrote: > This registers the current thread to be stopped next time an INT > signal is recieved, which happens when the user presses Ctrl-C.  Try > this: > >   user=> (Thread/sleep 1) > > Then press Ctrl-C before the 10 seconds are up, and you'll see: > >   java.l

Re: Proposal: remove auto-load of user.clj

2009-03-09 Thread Raffael Cavallaro
On Mar 9, 10:58 am, MikeM wrote: > Could you share what benefits you get by the auto-load of user.clj > early in the launch process? It allows the automatic loading of development utilities with each repl launch. It gets tiresome having to always do: (load "my-uils") (or, equivalently, (lo

Re: Proposal: remove auto-load of user.clj

2009-03-09 Thread Raffael Cavallaro
On Mar 9, 3:16 pm, MikeM wrote: > From the original post: "A command line option for loading user.clj > could be added for > repl usage." The whole discussion is about what the default should be since obviously one could make either behavior optional via command line switches. Since a majori

Re: Static type guy trying to convert

2009-03-10 Thread Raffael Cavallaro
Some of you may not know of Jon's behvior on comp.lang.lisp so some background will be useful here. He runs a business selling ocaml and f# consulting and training services and materials. He routinely posts insulting and inflammatory remarks about lispers and lisp in comp.lang.lisp. He admits hi

Re: Static type guy trying to convert

2009-03-10 Thread Raffael Cavallaro
On Mar 11, 12:44 am, e wrote: > h, that could sound like more of an endorsement than anything he could > have said, himself!  Afterall he could have chosen a dynamically typed > language for his business if he had wanted to. You have to be an expert in something to run a business selling

Re: cells/add-watch question

2009-03-11 Thread Raffael Cavallaro
On Mar 11, 11:20 am, linh wrote: > According to the API doc, add-watch must have 4 args: a key, a > reference, > its old-state and its new state. What I'm missing here is an addtional > arg that can be passed in some way to update-fn so that update-fn > knows what entries in my-atom has change

Re: cells/add-watch question

2009-03-11 Thread Raffael Cavallaro
On Mar 11, 1:24 pm, Raffael Cavallaro wrote: > ;; this just makes a big map atom where integer keys are associated > with integer values should rather be as follows to get integer keyword keys: (def my-atom (atom (assoc (apply hash-map (tak

Re: Static type guy trying to convert

2009-03-11 Thread Raffael Cavallaro
On Mar 11, 4:17 pm, "ntu...@googlemail.com" wrote: > I would appreciate it if you would consider his arguments instead of > discrediting him. His post is not insulting and contains valid > arguments. So please don't shoot the messenger. When the "messenger" is habitually insulting he loses cr

Bug in set?

2009-03-11 Thread Raffael Cavallaro
user=> (use 'clojure.set) nil user=> (set (list [:a 1] [:b 2])) #{[:b 2] [:a 1]} user=> (set (list [:a 1] [:b 2] [:c 3])) #{[:b 2] [:c 3] [:a 1]} user=> (difference *1 *2) #{[:c 3]} user=> (difference (set (list [:a 1] [:b 2])) (set (list [:a 1] [:b 2] [:c 3]))) #{} Is this a bug or am I just not

Re: Bug in set?

2009-03-11 Thread Raffael Cavallaro
On Mar 11, 11:43 pm, "Stephen C. Gilardi" wrote: > Here are the expressions and results in a simplified notation: > > #{a b c} - #{a b} => #{c} > > #{a b} - #{a b c} => #{} ok, so I was misunderstanding how difference works. I thought both would evaluate to #{c}. thanks --~--~-~--~--

Re: cells/add-watch question

2009-03-11 Thread Raffael Cavallaro
On Mar 11, 6:57 pm, linh wrote: > i didn't think of that. > if equality tests is instant, would finding out the difference also be > instant? > for example, is this instant: (difference new-set old-set) ? I don't think so: (defn set-difference-time-test [n] (let [s1 (set (apply hash-map

Re: Bug in set?

2009-03-12 Thread Raffael Cavallaro
On Mar 12, 11:28 am, Kyle Schaffrick wrote: > clojure.set/difference implements the "relative complement" operation. I > don't see a "symmetric difference" operation in clojure.set, but it > might be useful: exactly; I was naively thinking of symmetric difference since this is the ordinary en

Re: How to abort a long running operation at the SLIME REPL?

2009-03-15 Thread Raffael Cavallaro
shows how to do this basically, add the following to your user.clj (use 'clojure.contrib.repl-utils) (add-break-thread!) then whenever you type ctrl-c ctrl-c return, you'll get a break. --~--~-~--~~~-

Re: speed question

2009-04-02 Thread Raffael Cavallaro
If you change the color constructor you can get some nice color effects: (. setColor (let [scaled (Math/round (* value color-scale))] (Color. 255 (- 255 scaled) scaled))) will give you yellow and magenta for example --~--~-~--~~~---~--~~ You

Re: speed question

2009-04-03 Thread Raffael Cavallaro
this one is nice too: (defn draw-line [#^Graphics g y] (let [dy (- 1.25 (* y height-factor))] (doseq [x (range 0 width)] (let [dx (- (* x width-factor) 2.0)] (let [value (check-bounds dx dy) scaled (Math/round (* value color-scale)) xsca

Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-11-17 Thread Raffael Cavallaro
As the mention of Aquamacs in the title suggests, I'm on Mac OS X. I've read Bill Clementson's Blog on setting up clojure, and I'm not exactly a neophyte - I've been using slime with sbcl, openmcl, and other lisps for years. Nevertheless, even starting with an absolutely blank .emacs and freshly

Re: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-11-17 Thread Raffael Cavallaro
On Nov 17, 8:43 pm, "Bill Clementson" <[EMAIL PROTECTED]> wrote: > > Rather than ask someone to assemble a package and post it for you, it > is usually nicer (and a better learning experience) if you list > exactly what you did, and post the minimal config scripts that you the > tried out and wh

Re: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-11-17 Thread Raffael Cavallaro
? Remember the context: "Getting Started." The context is NOT bleeding edge developers who want the very latest build of everything. If you want the very latest slime, etc., you should be on your own. regards, Ralph Raffael Cavallaro, Ph.D. [EMAIL PROTECTED] --~--~-~--~~---

Re: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-11-18 Thread Raffael Cavallaro
On Nov 18, 1:46 am, "Cosmin Stejerean" <[EMAIL PROTECTED]> wrote: > What kind of bugs are acceptable for the > purpose of a known good combination? Is slime starting up sufficient? It's a whole lot better than slime *not* starting up. Again, context: "Getting Started." BTW, it's this sort of

Is this boolean behavior intentional?

2008-11-19 Thread Raffael Cavallaro
user> (def test-array (make-array (. Boolean TYPE) 100)) #'user/test-array user> (aget test-array 0) false user> (= (aget test-array 0) false) true user> (if (aget test-array 0) 'true-value 'false-value) true-value Same issue with when, and when-not as well. IOW, (aget some-boolean- array some-in

Re: Is this boolean behavior intentional?

2008-11-19 Thread Raffael Cavallaro
On Nov 19, 2:21 pm, Rich Hickey <[EMAIL PROTECTED]> wrote: > > Fixed (svn 1112) - thanks for the report. > > The problem is that the Java reflection APIs return new Boolean values > other than the canonic Boolean.TRUE and Boolean.FALSE when boxing > booleans, but for efficiency only canonic fals

Re: Dividing by zero and floating-point infinity

2008-11-20 Thread Raffael Cavallaro
On Nov 20, 10:23 am, "Mark H." <[EMAIL PROTECTED]> wrote: > I can't speak from Rich but I've noticed this behavior in other Lisp > implementations (like SBCL) that are built on C.  The Lisp > implementation changes the semantics of floating-point divide-by- > zero.  (The ANSI Common Lisp standa