Re: Vimclojure and Namespaces

2009-08-17 Thread Meikel Brandmeyer
Hi, On Aug 17, 6:08 am, Konrad Scorciapino scorciap...@gmail.com wrote: I'm new with Clojure, and I'm having a problem with Vimclojure and Namespaces. I'm following thishttp://java.ociweb.com/mark/clojure/article.htmltutorial, currently trying to evaluate the code below. If I evaluate the

Re: commute and ref-set

2009-08-17 Thread Meikel Brandmeyer
Hi, On Aug 17, 3:23 am, Mark Volkmann r.mark.volkm...@gmail.com wrote: Once commute has been called on a Ref (within a transaction of course), ref-set and alter cannot be called on it within the same transaction. This is enforced by the following code from the doSet method in

Re: Clojure Code Style

2009-08-17 Thread Daniel Lyons
On Aug 13, 2009, at 12:16 AM, Meikel Brandmeyer wrote: Also this function generates two classes, while the other two variants generate 6. Is there an easy way to tell how many classes a given function generates? — Daniel Lyons --~--~-~--~~~---~--~~ You

Re: Clojure Code Style

2009-08-17 Thread Meikel Brandmeyer
Hi, On Aug 17, 8:51 am, Daniel Lyons fus...@storytotell.org wrote: Also this function generates two classes, while the other two variants generate 6. Is there an easy way to tell how many classes a given function   generates? Not in general. But as a rule of thumb: every fn/#()

Re: commute and ref-set

2009-08-17 Thread Christophe Grand
Hi Mark and Meikel, On Mon, Aug 17, 2009 at 8:15 AM, Meikel Brandmeyer m...@kotka.de wrote: On Aug 17, 3:23 am, Mark Volkmann r.mark.volkm...@gmail.com wrote: Maybe it's there in case ref-set or alter was called on the Ref before commute. In that case, does that mean that the commute

Re: Vimclojure and Namespaces

2009-08-17 Thread Konrad Scorciapino
Hi Meikel, It now works. The problem was that the file was not accessible via the classpath. Thanks for the help! On Mon, Aug 17, 2009 at 3:04 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Aug 17, 6:08 am, Konrad Scorciapino scorciap...@gmail.com wrote: I'm new with Clojure, and I'm

Re: Clojure Code Style

2009-08-17 Thread Daniel Lyons
On Aug 17, 2009, at 1:27 AM, Meikel Brandmeyer wrote: Not in general. But as a rule of thumb: every fn/#() generates a class and hence everything using it: defn, comp, partial, letfn, thunk'ing in macros, ... Thanks! — Daniel Lyons --~--~-~--~~~---~--~~

Re: Vimclojure and Namespaces

2009-08-17 Thread Konrad Scorciapino
Hi Meikel, It now works. The problem was that the file was not accessible via the classpath. Thanks for the help! On Mon, Aug 17, 2009 at 3:04 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Aug 17, 6:08 am, Konrad Scorciapino scorciap...@gmail.com wrote: I'm new with Clojure, and I'm

Re: Pure-functional N-body benchmark implementation

2009-08-17 Thread Nicolas Oury
I was referring to the rules of the benchmark game. When you benchmark language, using another language is not fair. If you were to do your own program, of course you could use Java. However, in the particular circumstance, it is a bit annoying to use Java just to create a data structure type.

Re: Pure-functional N-body benchmark implementation

2009-08-17 Thread Mark Engelberg
Here's what I've learned from following this benchmark thread: From the various things I've read about Clojure's performance, I've always had this sense that: a) if you have a performance problem, there's probably some inner loop that needs to be optimized, and so b) you can use Clojure's

Re: Memory leak in vec (and maybe persistent!)?

2009-08-17 Thread Christophe Grand
On Sat, Aug 15, 2009 at 4:23 PM, Andy Fingerhut andy_finger...@alum.wustl.edu wrote: Not to say this ought to be done, but would it be possible to have no 'edit' field *at all* for persistent data structures (not even a null reference), and only an edit field at the root data structure of a

Re: ANN: VimClojure v2.1.2 released

2009-08-17 Thread kjellski
@Meikel: Yes, I do know, but at the start I´ve had some trouble with the ng server and the configuration. I thought, as a buildin-alternative it completes the possibilities. But nevertheless, it´s a quite nice hack I think. @ogcraft: I would recommend you to start reading the

ensure and commute

2009-08-17 Thread Mark Volkmann
I'm trying to understand this line in the run method of LockingTransaction.java. if(wasEnsured ref.tvals != null ref.tvals.point readPoint) throw retryex; This is in the loop where commutes get rerun during a commit. The question is how the Ref could have gotten a new committed value

Re: Pure-functional N-body benchmark implementation

2009-08-17 Thread David Nolen
On Mon, Aug 17, 2009 at 4:32 AM, Nicolas Oury nicolas.o...@gmail.comwrote: I was referring to the rules of the benchmark game. When you benchmark language, using another language is not fair. If you were to do your own program, of course you could use Java. However, in the particular

Re: Uncle Bob looking for clojure help!

2009-08-17 Thread David Nolen
Here are the major points: The algorithm requires that for about 400,000 points there will be ~8,000,000 iterations. This is a very tight loop. You cannot create anything in this loop, not even a regular Object, much less a temporary Clojure vector for doing vector math. The Java version avoids

Re: Pure-functional N-body benchmark implementation

2009-08-17 Thread e
i don't know much about this (haven't followed closely, lately), but do the new Transients come into play to somewhat address this? Sounds like they were designed just for this sort of thing: inner-loop optimization and low-level mutation that still works functionally to everything outside... On

Re: Pure-functional N-body benchmark implementation

2009-08-17 Thread Nicolas Oury
On this particular example, I think we are a bit further that what Transients currently offers. Even using a mutable primitive Java array results in code 2 or 3 times slower than the Java implementation of the benchmarks. I have no doubt the struct and transients in Clojure will allow to do that

Jwt from Clojure?

2009-08-17 Thread rb
HI, Jwt (http://www.webtoolkit.eu/jwt ) is a java translation of the C++ web toolkit (http://www.webtoolkit.eu/wt ) I'd like to develop a web app in clojure based on Jwt, but Jwt apps need to run in a servlet container. What's the best path to follow in that case? Is developing a Ring adapter

Re: Pure-functional N-body benchmark implementation

2009-08-17 Thread David Nolen
On Sun, Aug 16, 2009 at 6:50 AM, Nicolas Oury nicolas.o...@gmail.comwrote: Dear all, The good news: I have a version of the N-body benchmark that goes as fast as java. The bad news: I am cheating a little bit... You're only cheating if you care about the fantasy world that is

Re: Jwt from Clojure?

2009-08-17 Thread Adrian Cuthbertson
Hi Raphaël, If you're going to drive your app (and server) from clojure, then you can use Compojure's jetty.clj module. This allows you to create a servlet holder (in which you can add an instantiated Jwt servlet on a jetty url path). Compojure also supports the Ring protocol, so you can also

Re: Pure-functional N-body benchmark implementation

2009-08-17 Thread Bradbev
On Aug 17, 1:32 am, Nicolas Oury nicolas.o...@gmail.com wrote: I was referring to the rules of the benchmark game. When you benchmark language, using another language is not fair. If you were to do your own program, of course you could use Java. However, in the particular circumstance, it is

Re: Pure-functional N-body benchmark implementation

2009-08-17 Thread Nicolas Oury
Seems to mean that I was wrong and that the cost is both in bound check and unpacking the indices, mostly the second one. On Mon, 2009-08-17 at 09:25 -0700, Bradbev wrote: On Aug 17, 1:32 am, Nicolas Oury nicolas.o...@gmail.com wrote: I was referring to the rules of the benchmark game. When

deadlocks and race conditions

2009-08-17 Thread Mark Volkmann
Just checking my understanding. It seems to me that it is not possible for Clojure to remove the possibility of writing code that has race conditions. I could write code in which two threads each change the value of the same Ref inside a transaction. Let's say the Ref starts with a value of 2,

Re: deadlocks and race conditions

2009-08-17 Thread CuppoJava
I don't have enough knowledge to answer the deadlock question. But I can offer you my opinion about your question on race conditions. In your example, the result WILL depend on which transaction is run first. However I think practically this isn't a problem, because of the following: As a

Re: deadlocks and race conditions

2009-08-17 Thread Michael Reid
Hi, Ditto on the ordering example. Clojure can't infer which order your code needs to run any more than it can figure out what your code is supposed to do. On the deadlock question, it is my understanding from a prior post by Rich that Clojure's STM acquires locks in such a way that deadlocks

Re: deadlocks and race conditions

2009-08-17 Thread Mark Volkmann
On Mon, Aug 17, 2009 at 2:47 PM, Michael Reidkid.me...@gmail.com wrote: Hi, Ditto on the ordering example. Clojure can't infer which order your code needs to run any more than it can figure out what your code is supposed to do. Okay. I was pretty sure that was the case, but just wanted to

Re: Augmenting the defn attr-map

2009-08-17 Thread tsuraan
The official docs for this are at: http://clojure.org/ special_forms#let . That's a great link. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

does index-filter deserve to be in seq-utils?

2009-08-17 Thread Stuart Halloway
I wrote this for the book: (defn index-filter [pred coll] (when pred (for [[idx elt] (indexed coll) :when (pred elt)] idx))) and I keep finding myself needing it all over the place. Is there a better idiom for finding *positions* of things in a sequence, rather than the things

Re: does index-filter deserve to be in seq-utils?

2009-08-17 Thread Sean Devlin
Hmmm... this seems like a cool way to do this. Could you provide an example for when you need to this? A few use cases would help me understand the intent. Sean On Aug 17, 7:18 pm, Stuart Halloway stuart.hallo...@gmail.com wrote: I wrote this for the book: (defn index-filter [pred coll]  

Re: Pure-functional N-body benchmark implementation

2009-08-17 Thread Aaron Cohen
On Mon, Aug 17, 2009 at 7:45 PM, Mark Engelbergmark.engelb...@gmail.com wrote: On Mon, Aug 17, 2009 at 9:25 AM, Bradbevbrad.beveri...@gmail.com wrote: I found another 2-3x speed up by coercing the indexes with (int x), ie (defmacro mass [p] `(double (aget ~p (int 0 Which makes me

Idiom for array slicing

2009-08-17 Thread Mark Triggs
Hi all, Is there an idiom for what I'm doing below, or does a function already exist? (let [vowels (slice abcdefghijklmnopqrstuvwxyz 0 4 8 14 20)] vowels) = (\a \e \i \o \u) A possible implementation: (defn slice Return the items in coll at index positions

Re: Idiom for array slicing

2009-08-17 Thread Sean Devlin
My $.02 (defn slice [indices coll] (let [idx (filter #( % (count coll) (set indices))] (map (partial nth coll) idx))) I changed the order of your arguments to accommodate map operations (which you're gonna need to parse a log file). Alternatively, you could have slice generate a

Re: Idiom for array slicing

2009-08-17 Thread jan
Mark Triggs mark.h.tri...@gmail.com writes: Is there an idiom for what I'm doing below, or does a function already exist? (let [vowels (slice abcdefghijklmnopqrstuvwxyz 0 4 8 14 20)] vowels) = (\a \e \i \o \u) Here's how I would do it: (defn extract [coll keys]

Re: Idiom for array slicing

2009-08-17 Thread Sean Devlin
Actually, now that I think about this, I do have another solution. I've posted a proposal for a proj fn in the dev list. Read up here http://groups.google.com/group/clojure-dev/browse_thread/thread/155c8b9893d673bc (defn slice-c [ indices] (apply proj (map (fn[index]

Re: Idiom for array slicing

2009-08-17 Thread Jan Marecek
(defn slice [coll keys]  (remove nil? (map #(get coll %) keys))) this doesn't handle nils, here is a better definition (defn slice [coll keys] (let [not-found (Object.)] (remove #(identical? % not-found) (map #(get coll % not-found) keys -- jan

Re: does index-filter deserve to be in seq-utils?

2009-08-17 Thread Richard Newman
if this works exactly like indexOf in java, then it seems like it should be in the core ... but as position, or pos, based on your description. Why the core? I'm mentioned this before: symmetry, since nth is there. Others would argue, leave it out since there's a way to do it from

Re: deadlocks and race conditions

2009-08-17 Thread J. McConnell
On Mon, Aug 17, 2009 at 1:56 PM, Mark Volkmann r.mark.volkm...@gmail.comwrote: Does Clojure STM eliminate the possibility of deadlock? When two transactions have a contention for the same Ref, Clojure gives preference to the transaction that has been running the longest (unless it has only

Re: Idiom for array slicing

2009-08-17 Thread Mark Triggs
Thanks all. So combining a few suggested ideas: (defn slice Return the items in coll at index positions keys. (slice [0 4 6] \abcdefg\) = (\\a \\e \\g) [keys coll] (let [max-idx (apply max keys) keyset (set keys)] (map second (filter (fn [[idx _]]