Mysterious ClassFormatError after simple code change.

2009-07-05 Thread John Harrop
I had this: (defn- subexpressions-of-sum** [[n p] terms] (let-print [sum (cons '+ (map #(factor-term % n p) terms)) prod (rest (make-product* n p))] (concat [sum] (subexpressions-of-product (cons sum prod) in a source file with other definitions. Load-file worked. I then change

Re: Mysterious ClassFormatError after simple code change.

2009-07-05 Thread John Harrop
something that large from a number being changed. This is frankly quite baffling. The changes to the function are innocent from a large-literal or pretty much any other perspective. On 7/5/09, Stephen C. Gilardi wrote: > On Jul 5, 2009, at 2:01 AM, John Harrop wrote: > >> and got: &g

Re: Mysterious ClassFormatError after simple code change.

2009-07-06 Thread John Harrop
On Mon, Jul 6, 2009 at 8:53 AM, Chouser wrote: > > On Sun, Jul 5, 2009 at 3:51 PM, John Harrop wrote: > > > > This is frankly quite baffling. The changes to the function are > > innocent from a large-literal or pretty much any other perspective. > > Both your func

Re: Is this unquote dangerous?

2009-07-06 Thread John Harrop
> > Or if you really do need a list: > > (for [x [1 2 3]] (cons 'some-symbol (list x))) > Why not (for [x [1 2 3]] (list 'some-symbol x)) ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post t

Re: Mysterious ClassFormatError after simple code change.

2009-07-06 Thread John Harrop
On Mon, Jul 6, 2009 at 3:58 PM, Emeka wrote: > (defn- subexpressions-of-sum** [[n p] terms] > (let-print [sum (cons '+ (map #(factor-term % n p) terms)) >prod (rest (make-product* n p))] >(cons sum > (map #(cons '* (cons sum (rest %))) >(concat prod (subexpressions-of-p

Re: Mysterious ClassFormatError after simple code change.

2009-07-07 Thread John Harrop
On Mon, Jul 6, 2009 at 7:50 PM, Richard Newman wrote: > > > Since it's not apparently a simple bug in my function above, but > > something about a combination of that version of that function and > > some other part of my code, I can't think of a way to track the > > cause down short of the very

Re: Mysterious ClassFormatError after simple code change.

2009-07-07 Thread John Harrop
On Mon, Jul 6, 2009 at 11:25 PM, John Harrop wrote: > On Mon, Jul 6, 2009 at 7:50 PM, Richard Newman wrote: > >> Have you tried simpler things like splitting the offending function >> into a separate namespace, or seeing what happens with (or without) >> AOT compila

Re: Mysterious ClassFormatError after simple code change.

2009-07-07 Thread John Harrop
On Tue, Jul 7, 2009 at 9:30 AM, Stephen C. Gilardi wrote: > > On Jul 7, 2009, at 5:51 AM, John Harrop wrote: > > Somehow, code that is treated as valid when compiled a function at a time >> is treated as invalid when compiled all at once. That pretty much proves >> it

Passing primitives from an inner loop to an outer loop efficiently

2009-07-07 Thread John Harrop
Problem: Passing primitives from an inner loop to an outer loop efficiently. Here is what I've found. The fastest method of result batching, amazingly, is to pass out a list and: (let [foo (loop ... ) x (double (first foo)) r1 (rest foo) y (double (first r1)) r2 (rest r1) z (double (first r2))] .

Re: Passing primitives from an inner loop to an outer loop efficiently

2009-07-08 Thread John Harrop
On Wed, Jul 8, 2009 at 3:42 AM, Frantisek Sodomka wrote: > > If result is a vector v, then from these 4 cases: > (let [v [1 2 3]] > (let [[a b c] v] a b c) > (let [a (v 0) b (v 1) c (v 2)] a b c) > (let [a (nth v 0) b (nth v 1) c (nth v 2)] a b c) > (let [x (first v) r1 (rest v) y (first r1) r

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread John Harrop
On Wed, Jul 8, 2009 at 5:14 AM, Robert Campbell wrote: > > Thanks Daniel, that makes perfect sense, especially about having > random - and forgotten - code in the image. I have a lot of this > during my exploration sessions. Perhaps instead of saving an image, it should be able to save a transc

Re: Homoiconicity and printing functions

2009-07-08 Thread John Harrop
On Wed, Jul 8, 2009 at 9:11 AM, Mike wrote: > One of the things that drew me to Clojure was the fact that it's > homoiconic (and my previous lisp [Scheme] was not necessarily), which > means code is data, macro writing is easy etc. etc. > > What I'm missing is why I can't print a function. I und

Re: Passing primitives from an inner loop to an outer loop efficiently

2009-07-08 Thread John Harrop
Interesting. How are these timings affected if you add in the time taken to pack the list or vector in the first place, though? I have the feeling it may be slightly cheaper to unpack a vector, but noticeably cheaper to pack a list... --~--~-~--~~~---~--~~ You recei

Re: Help with example from "A Field Guide to Genetic Programming"

2009-07-08 Thread John Harrop
On Wed, Jul 8, 2009 at 1:57 PM, Robert Campbell wrote: > If it's okay, could somebody explain the difference between what's > happening here: > > user> (def my-func (list + 1 2)) > #'user/my-func > user> (my-func) > ; Evaluation aborted. > > and here: > > user> (def my-func (list + 1 2)) > #'user

Re: Passing primitives from an inner loop to an outer loop efficiently

2009-07-08 Thread John Harrop
On Wed, Jul 8, 2009 at 4:57 PM, Frantisek Sodomka wrote: > > So far it seems that vectors win in Clojure: > > (timings 3e5 > (let [v (vector 1 2 3) a (nth v 0) b (nth v 1) c (nth v 2)] (+ a b > c)) > (let [lst (list 1 2 3) a (nth lst 0) b (nth lst 1) c (nth lst 2)] (+ > a b c))) > > => > 680.63

Re: Clojure in Clojure?

2009-07-09 Thread John Harrop
On Thu, Jul 9, 2009 at 11:10 AM, tmountain wrote: > > I just finished watching the Bay Area Clojure Meetup video, and Rich > spent a few minutes talking about the possibility of Clojure in > Clojure. The prospect of having Clojure self-hosted is incredibly > cool, but it brought a few questions t

Re: Best way to create nonref variable?

2009-07-10 Thread John Harrop
On Thu, Jul 9, 2009 at 10:29 PM, J. McConnell wrote: > You can try with-local-vars. I'm not sure of the performance > characteristics of this versus using an atom, but it certainly feels > more imperative: It's slow. I suspect it (and binding) uses Java's ThreadLocal, which is slow. Loop/recur

*math-context*

2009-07-10 Thread John Harrop
It would be useful to have a *math-context* or similar that had a sensible default and could be set with binding to affect bigdec calculations within the temporal scope of said binding. --~--~-~--~~~---~--~~ You received this message because you are subscribed to th

Re: *math-context*

2009-07-10 Thread John Harrop
On Fri, Jul 10, 2009 at 9:22 AM, Rich Hickey wrote: > On Jul 10, 9:01 am, Chouser wrote: > > On Fri, Jul 10, 2009 at 7:14 AM, John Harrop > wrote: > > > It would be useful to have a *math-context* or similar that had a > sensible > > > default and could be

ArithmeticException with doubles

2009-07-10 Thread John Harrop
This is odd: user=> (/ 1.0 0.0) # Shouldn't it be Double/POSITIVE_INFINITY? --~--~-~--~~~---~--~~ 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 Note that post

Re: Compilation troubles...

2009-07-13 Thread John Harrop
On Mon, Jul 13, 2009 at 3:11 PM, Morgan Allen wrote: > It's a shame about the lack of official support for java-side > invocation- the bulk of my code is still implemented in java (largely > for efficiency reasons), so it would be handy to be able to initiate > things largely from that side. It

Re: Performance question (newbie)

2009-07-15 Thread John Harrop
On Wed, Jul 15, 2009 at 11:39 AM, B Smith-Mannschott wrote: > An explicit loop with some type hints is faster, though likely not as > fast as Java: > > (defn sum-of-range-4 [range-limit] > (loop [i (int 1) s (long 0)] >(if (< i range-limit) > (recur (inc i) (+ s i)) > s))) > > This

Re: EY map reduce contest

2009-07-15 Thread John Harrop
On Wed, Jul 15, 2009 at 4:53 AM, hosia...@gmail.com wrote: > > > http://www.engineyard.com/blog/2009/programming-contest-win-iphone-3gs-2k-cloud-credit/ > > Has anyone got access to hundreds of thousands of machines that I > could borrow for 30 hours ? ;) Don't know any botnet herders; sorry. :)

Re: Clojure vectors

2009-07-15 Thread John Harrop
On Wed, Jul 15, 2009 at 12:58 PM, Mark Engelberg wrote: > > It looks like stack-rot is going to be the bottleneck in your app > since it requires traversing the whole vector to build the new one, > but I think the list-based implementation would be a bit worse, so I > think your choice to use vecto

Re: How to achieve indirection?

2009-07-16 Thread John Harrop
On Thu, Jul 16, 2009 at 11:34 AM, Dragan wrote: > Thanks for the tip, I meant something else. > Let's say that I want to write a function do-something. There could be > 2 implementations: do-something-quickly and do-something-elegantly. > The parameters are the same and there are no differences i

Re: Very minor problem in the REPL

2009-07-17 Thread John Harrop
On Fri, Jul 17, 2009 at 11:31 AM, Stephen C. Gilardi wrote: > It looks like somehow you're seeing a very old REPL or it's not the default > REPL you get from launching Clojure via clojure.main. > I can confirm the described behavior for the enclojure REPL. --~--~-~--~~~--

Re: Is there a standard function testing if a sequence starts with a sequence

2009-07-17 Thread John Harrop
On Fri, Jul 17, 2009 at 4:41 PM, Mark Engelberg wrote: > > On Fri, Jul 17, 2009 at 1:32 PM, samppi wrote: > > > > Is there a function in clojure.core or clojure.contrib so that: > > (and (mystery-fn '(a b c d) '(a b)) > >(not (mystery-fn '(a b c d) '(a b d > > > how about something li

Re: "let" a variable number of bindings

2009-07-18 Thread John Harrop
On Fri, Jul 17, 2009 at 11:52 PM, Rowdy Rednose wrote: > > How can I lexically bind names like "let" does in a macro, when names > and values for those bindings are passed in? > > This here works fine when I pass a literal collection: > > (defmacro let-coll > [coll & body] > `(let ~(vec coll) ~.

Re: "let" a variable number of bindings

2009-07-18 Thread John Harrop
On Sat, Jul 18, 2009 at 1:22 AM, Meikel Brandmeyer wrote: > Using eval is not really a solution. > > (def foo '[a 1 b 2]) > (let-coll foo ...) > > will probably work with eval, but > > (let [foo '[a 1 b 2]] > (let-coll foo ...)) > > will not. > No, for that you need to make the "macro" run-time

Re: Simple data structure access macro

2009-07-21 Thread John Harrop
On Mon, Jul 20, 2009 at 4:31 PM, Moses wrote: > > I come primarily from a perl programming background, but am trying > to learn Clojure. > > I'm looking for a clojure equivalent to the following. > > Perl: > > my $nestedDS = [ "foo", { hi => there, hello => ["buddy"] }, "hi"] > > my $foo =

Re: Confusion with apply.

2009-07-22 Thread John Harrop
On Wed, Jul 22, 2009 at 5:17 PM, mmwaikar wrote: > So if this is the intended behavior of apply, which function should I > use in this case? Is there anything in Clojure where I can apply any > user-defined function to each and every element of a list one-by-one? Use map: user=> (map #(* 5 %)

Re: How to write performant functions in clojure (and other functional languages)

2009-07-26 Thread John Harrop
On Sat, Jul 25, 2009 at 4:40 PM, atucker wrote: > > I wonder if any of the Clojurians on here might like to describe how > one might write the factorial function as a parallel one? Taking > advantage of the associativity of multiplication, along the lines of > > 16! = (((1*2)*(3*4)) * ((5*6)*(7*

Re: gen-class & bytecode for method implementation

2009-07-27 Thread John Harrop
On Mon, Jul 27, 2009 at 3:37 PM, Mark Addleman wrote: > > I have written some Clojure code to implement java.lang.CharSequence > that is constructed with a length and an ISeq of strings. I need this > because I want to pass the resulting CharSequence into Java's regex > library. I got the thing

Re: a denilling macro

2009-07-28 Thread John Harrop
On Mon, Jul 27, 2009 at 8:33 PM, nchubrich wrote: > Anyway I'd appreciate any critiques of the implementation; whether > it's a useful thing or not; if there are more idiomatic ways of doing > the same thing; and, if yes-no to the aforetwo, where's the best place > to add this functionality? W

Re: Problem with gen-class

2009-07-28 Thread John Harrop
On Tue, Jul 28, 2009 at 1:47 AM, Laurent PETIT wrote: > Do you know what could cause this "repetitive method name/signature in > class" ? >:exposes-methods {addPages super-addPages})) > Is it possible that exposing both addPages and the superclass addPages causes this? Try it without super

Re: Newbish question. Does anyone have any example code for playing a wav sound file?

2009-07-28 Thread John Harrop
On Mon, Jul 27, 2009 at 9:00 PM, Rayne wrote: > > I've googled around, and found several ways to do this in Java, but > I've not been successful in translating the less-complex examples. I'm > wondering, how would an experienced Clojurian go about doing this in > Clojure? On my system, the foll

Re: Parallel garbage collection worthwhile?

2009-07-29 Thread John Harrop
On Wed, Jul 29, 2009 at 2:59 AM, Daniel Lyons wrote: > Probably it would help to try and implement a lazy > list of the Fibonacci sequence before looking at that code, and then > maybe try some other mathematical sequences that are a little easier > to construct too. > Using the super-lazy-seq ma

Re: REQUEST: Add seqable? to core

2009-07-29 Thread John Harrop
How about defining seqable? in terms of whether seq works, using try catch? Or better yet: (defmacro if-seq "If (seq obj) makes sense, evaluates expr1 with name bound to (seq obj); otherwise evaluates expr2." [[name obj] expr1 expr2] `(let [[~name failed#] (try [(s

Re: Possible bug report

2009-07-29 Thread John Harrop
On Wed, Jul 29, 2009 at 6:09 PM, Jason Wolfe wrote: > > Is this a bug? > > user> (eval `(make-array ~Byte/TYPE 2)) > ; Evaluation aborted. (ExceptionInInitializerError) > > Compare: > > user> (eval `(make-array ~Byte 2)) > # > > user> (eval `(make-array Byte/TYPE 2)) > # > > user> (make-array (ev

Bug? Definline arguments multiply evaluated.

2009-07-30 Thread John Harrop
user=> (definline addsq [a b] `(+ (* ~a ~a) (* ~b ~b))) #'hxr.clj.util/addsq user=> (addsq (do (println "a evaluated") 1) 1) a evaluated a evaluated 2 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: Idiomatic parsing of objects from several lines of a text file

2009-07-31 Thread John Harrop
On Thu, Jul 30, 2009 at 9:37 PM, Richard Newman wrote: > I suppose in Clojure we could use a real arrow character, with UTF-8 > available in symbol names... I don't know about you, but I personally prefer to only use symbols that I can actually type. Copying and pasting from Character Map kind

Re: Trampolined backtracking maze solver

2009-08-02 Thread John Harrop
On Sun, Aug 2, 2009 at 5:48 AM, James Sofra wrote: > (defn tile-in-bounds? [[x y] maze] > (let [h (count maze)] >(if (and (>= y 0) (>= x 0) (< y h)) > (if (< x (count (maze y))) >true (defn tile-in-bounds? [[x y] maze] (and (>= y 0) (>= x 0) (< y (count maze)) (< x (coun

Re: Newbie question on using Java Libraries

2009-08-03 Thread John Harrop
On Mon, Aug 3, 2009 at 4:16 AM, Adie wrote: > > Good Afternoon folks, > > I am a newbie to Clojure, coming from CL, with very little Java > background. > I am trying to use the 'javax.persistence' libraries, but i just cant > seem to import it properly > > for e.g > (import '(javax.persistence Pe

Re: Memfn: what does it mean?

2009-08-03 Thread John Harrop
On Mon, Aug 3, 2009 at 8:53 AM, Mike DeLaurentis wrote: > > I believe it stands for "member function". From the doc string: > > "Expands into code that creates a fn that expects to be passed an > object and any args and calls the named instance method on the > object passing the args. Use when

Re: Memfn: what does it mean?

2009-08-03 Thread John Harrop
On Mon, Aug 3, 2009 at 3:45 PM, Richard Newman wrote: > > > user=> (macroexpand-1 '(memfn add x y)) > > (clojure.core/fn [target__4193__auto__ x y] (. target__4193__auto__ > > (add x y))) > > > > That is, basically (fn [object x y] (.add object x y)). > > .add is macroexpanded into the more gener

Re: Minor macro help

2009-08-03 Thread John Harrop
On Mon, Aug 3, 2009 at 5:43 PM, samppi wrote: > I'm getting stuck because a-map always gets passed into my-macro > as a symbol. > > (defmacro my-macro [a-map & forms] ; Naive implementation >`(binding ~(vec (process-a-map a-map)) ~...@forms)) Try (defmacro my-macro [a-map & forms] ; Naive

Re: Transient Data Structures

2009-08-03 Thread John Harrop
On Mon, Aug 3, 2009 at 7:27 PM, CuppoJava wrote: > > Hi Rich, > This is a very useful addition thanks. I personally find the O(1) > transformation to and back most useful. > > I have a question about capturing the return values of conj! and > assoc!. > > in this code: > (let [v (transient []) >

Re: Minor macro help

2009-08-03 Thread John Harrop
On Mon, Aug 3, 2009 at 8:01 PM, CuppoJava wrote: > > You can use eval to retrieve the value of a-map when the macro is > expanded. > > (let [value (eval a-map)] > `(binding ~(vec (process-a-map value)) ~...@forms)) > > I've programmed some substantial programs now in Clojure though, and > I've ne

Re: Minor macro help

2009-08-04 Thread John Harrop
Very clever, Meikel. --~--~-~--~~~---~--~~ 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 Note that posts from new members are moderated - please be patient wit

Re: Memfn: what does it mean?

2009-08-04 Thread John Harrop
On Tue, Aug 4, 2009 at 2:22 AM, Meikel Brandmeyer wrote: > > Hi, > > On Aug 3, 10:10 pm, John Harrop wrote: > > > (defn and-ns > > "A non-short-circuiting \"and\" usable in reduce etc." > > ([] true) > > ([a] a) > > ([

Re: Transient Data Structures

2009-08-04 Thread John Harrop
On Tue, Aug 4, 2009 at 1:39 PM, Rich Hickey wrote: > > On Tue, Aug 4, 2009 at 1:32 PM, John Newman wrote: > > > > I'm a noob, so this is probably a dumb question but, how does this work > with > > closures? Can transients be closed over? > > > > Like, > > > >> (defn make-transient-counter [init-v

Re: Transient Data Structures

2009-08-05 Thread John Harrop
On Tue, Aug 4, 2009 at 5:50 PM, Rich Hickey wrote: > On Aug 4, 4:31 pm, John Harrop wrote: > > What about things like: > > > > (persistent! > > (reduce > > (fn [x [i v]] (assoc! x i v)) > > (transient (vec (repeat 0 (reduce max (map first > &

Re: Reflection warning: reference to field getClass can't be resolved.

2009-08-05 Thread John Harrop
On Tue, Aug 4, 2009 at 7:46 PM, Vagif Verdi wrote: > > When reflection warning is on, i get 2 warnings on every my file: > > reference to field getClass can't be resolved. That one is very weird, because getClass is a method of java.lang.Object. It should always be possible to resolve that one

Miscellanea prompted by a comp.lang.lisp post about Clojure

2009-08-05 Thread John Harrop
I just saw someone post a bunch of Clojure code to comp.lang.lisp one function from which was: (defn partition-with [pred coll] (loop [in coll curr [] out []] (if (empty? in) (conj out curr) (let [obj (first in)] (if (pred obj) (recur (rest in) [] (conj out curr

Re: Newbie question: Writing a GUI with clojure

2009-08-05 Thread John Harrop
On Tue, Aug 4, 2009 at 10:33 PM, Joe Van Dyk wrote: > > Hey, > > New to Java and Clojure. My possibly relevant experience is with Gtk > and Ruby and C++ programming. > > I'd like to develop a GUI in Clojure. I'm guessing I want to use > Swing. This application will be targeted towards scientis

Re: Question about pmap

2009-08-06 Thread John Harrop
Cache misses are a possibility; try the integer version with long, so the size of the data is the same as with double. The other possibility I'd consider likely is that the JDK you were using implements caching in Double.valueOf(double). This could be dealt with if Clojure boxing directly called ne

Re: Clojure performance tests and clojure a little slower than Java

2009-08-07 Thread John Harrop
On Thu, Aug 6, 2009 at 6:57 PM, Andy Fingerhut < andy_finger...@alum.wustl.edu> wrote: > You are correct. I've updated that file: > > > http://github.com/jafingerhut/clojure-benchmarks/blob/bb9755bdeeccae84a9b09fbf34e45f6d45d4b627/RESULTS > Could you post the Mandelbrot code you use? Because I k

Re: Clojure performance tests and clojure a little slower than Java

2009-08-07 Thread John Harrop
Your core loop seems to be: (loop [zr (double 0.0) zi (double 0.0) zr2 (double 0.0) zi2 (double 0.0) iterations-remaining iterations-remaining] (if (and (not (neg? iterations-remaining)) (< (+ zr2 zi2) limit-square)) (let [new-zi (double (+

Re: Clojure performance tests and clojure a little slower than Java

2009-08-08 Thread John Harrop
On Fri, Aug 7, 2009 at 9:19 PM, Andy Fingerhut < andy_finger...@alum.wustl.edu> wrote: > > What I suggest is > > > > (loop [zr (double 0.0) > >zi (double 0.0) > >i (int (inc iterations-remaining))] > > (let [zr2 (* zr zr) > > zi2 (* zi zi)] > > (if (and (not (= 0 i))

Re: Durable transactions in practice?

2009-08-08 Thread John Harrop
On Sat, Aug 8, 2009 at 2:50 AM, cody koeninger wrote: > > Assuming people aren't patching clojure ala dave griffith's external > transactions patch in the group files, what are people doing in > practice to durably store the state of refs? > > Storing within a transaction and somehow ensuring you

Re: Clojure performance tests and clojure a little slower than Java

2009-08-08 Thread John Harrop
On Sat, Aug 8, 2009 at 5:23 AM, Mark Engelberg wrote: > > On Fri, Aug 7, 2009 at 5:14 PM, John Harrop wrote: > > (if (and (not (= 0 i)) (< (+ zr2 zi2 limit-square))) > > I believe that (zero? i) is faster than (= 0 i). On primitive int

Re: binding and bundles of variables

2009-08-08 Thread John Harrop
On Sat, Aug 8, 2009 at 9:52 AM, Rich Hickey wrote: > > On Sat, Aug 8, 2009 at 5:53 AM, Meikel Brandmeyer wrote: > > Hi, > > > > Am 08.08.2009 um 02:52 schrieb samppi: > > > >> Great, thanks. Is clojure.lang.Var/pushThreadBindings a public, > >> supported part of the API? Can I use it without fear

Re: Clojure performance tests and clojure a little slower than Java

2009-08-09 Thread John Harrop
On Sun, Aug 9, 2009 at 3:06 AM, Andy Fingerhut < andy_finger...@alum.wustl.edu> wrote: > I did two runs for each version, with the only difference between them > being replacing the (zero? i) expression in function 'dot' with a > different expression, as indicated below. (zero? i) is a clear winn

Re: How to create structure with a seq of keys

2009-08-10 Thread John Harrop
On Sun, Aug 9, 2009 at 8:55 PM, David Nolen wrote: > Sounds like you want apply: > (apply fn args) > Indeed. Since create-struct (not create-structure!) is a function, this should work. It wouldn't work with a macro, though. --~--~-~--~~~---~--~~ You received th

Re: Commenting Code (Was: Re: Clojure as a First Language)

2009-08-10 Thread John Harrop
On Sun, Aug 9, 2009 at 12:47 PM, Lauri Pesonen wrote: > > 2009/8/8 Luc Prefontaine : > > > I totally agree no comments is not good at all but JavaDoc style comments > in > > Clojure ? I pray you all, please stay away of it : > > I was quite taken by this scheme style guide recently: > > http:

Re: core.clj: 'into' definition

2009-08-11 Thread John Harrop
On Tue, Aug 11, 2009 at 6:39 AM, Krukow wrote: > > I was browsing through core when I noticed something I didn't > understand in 'into' (from core.clj): > > ;redef into with batch support > (defn into > "Returns a new coll consisting of to-coll with all of the items of > from-coll conjoined." >

Re: binary serialization

2009-08-11 Thread John Harrop
On Mon, Aug 10, 2009 at 10:57 PM, Kyle R. Burton wrote: > On Mon, Aug 10, 2009 at 10:42 PM, Kyle R. Burton > wrote:Sorry, forgot to offer up the inverse of freeze, thaw: > > (defn thaw [bytes] > (with-open [bais (java.io.ByteArrayInputStream. bytes) > ois (java.io.ObjectInputStream.

Re: binary serialization

2009-08-11 Thread John Harrop
On Tue, Aug 11, 2009 at 12:17 AM, fft1976 wrote: > I don't know JVM too well, but I think no efficient user-level > solution is possible. Why? To take care of substructure sharing, you > need to remember a set of shareable values that have already been > serialized, and do "reference equality" co

Re: binary serialization

2009-08-11 Thread John Harrop
On Tue, Aug 11, 2009 at 2:31 PM, fft1976 wrote: > On Aug 11, 8:36 am, John Harrop wrote: > > > System.identityHashCode() and IdentityHashMap. These use a hash that > > respects reference equality. So one in fact can implement one's own > > serialization that is O(

Re: Clojure performance tests and clojure a little slower than Java

2009-08-11 Thread John Harrop
On Fri, Aug 7, 2009 at 8:14 PM, John Harrop wrote: > Your core loop seems to be: > (loop [zr (double 0.0) > zi (double 0.0) > zr2 (double 0.0) > zi2 (double 0.0) > iterations-remaining iterations-remaining] > (if (and (not (neg?

Re: Can Clojure be as fast as Java?

2009-08-12 Thread John Harrop
On Wed, Aug 12, 2009 at 5:25 AM, Piyush Ranjan wrote: > This is a troll question. I have seen similar questions posted on other > forums about languages like ruby, CL, Haskell, Prolog, C, C++, fortran, > bigloo(?) etc by the same poster. Hmm. fft1976 = WrexSoul? --~--~-~--~~---

Re: Clojure Code Style

2009-08-12 Thread John Harrop
On Thu, Aug 13, 2009 at 12:34 AM, Richard Newman wrote: > This is the difference between 'conventional' and point-free style, by > the way. Many people view point-free as being somehow more elegant, > and I'm generally inclined to agree... apart from in cases like your > example, where a ton of p

Re: clojure success story ... hopefully :-)

2009-08-15 Thread John Harrop
On Fri, Aug 14, 2009 at 7:18 PM, bradford cross wrote: > Hi Chad, yep, that was me. We do hope to open source some stuff soon. > > First will probably be our wrappers for cascading/hadoop and s3. > > Next might be some core language extensions which might be good in contrib > or some other lib. >

Re: what's the appropriate way to process inner nested list (or vector) in clojure?

2009-08-16 Thread John Harrop
On Sun, Aug 16, 2009 at 1:30 AM, botgerry wrote: > > Hello,all > > new to functional programming, I have one nested dynamic vecter just > like this: > > (def a [[1 2 3 4] ["ok" 89 22] [25 78 99] ...]] > > it has to support ops: > 1* add new item,it's easy: eg. (conj a ["metoo" "oops"] ) > 2*

Re: Idiom for array slicing

2009-08-18 Thread John Harrop
On Mon, Aug 17, 2009 at 11:35 PM, Mark Triggs wrote: > > 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) > keyse

Re: Arity count

2009-08-19 Thread John Harrop
On Wed, Aug 19, 2009 at 10:03 AM, Achim Passen wrote: > Beware! This snippet relies on unexposed details of clojure's current > implementation. It might stop working tomorrow, so it's definitely not > intended for production use, but it might help with debbuging/exploring. Meanwhile, for declare

Re: Can dosync transaction result computation be parallelized over multiple threads?

2009-08-19 Thread John Harrop
(def *dosync-counts* (atom {}) (defn avg-in [map key val] (let [[avg cnt] (get map key [0 0])] (assoc map key [(/ (+ (* avg cnt) val) (inc cnt)) (inc cnt)]))) (defmacro logged-dosync [& body] `(let [count# (atom 0)] (dosync (swap! count# inc) ~...@body) (swap! *dosy

Re: New string utilities library ready

2009-08-19 Thread John Harrop
On Thu, Aug 20, 2009 at 12:45 AM, samppi wrote: > > For me, I'd like it if the core functions had the "data" as the first > argument, but have a special function—I can't come up with a better > name than "partial-2"—so that (partial-2 function opt1 opt2 opt3) is > equivalent to (fn [data] (functi

Re: we offer cheap sport shoes men's shoe(www.salegood8.com) casual shoe fashion shoe

2009-08-25 Thread John Harrop
What the hell? --~--~-~--~~~---~--~~ 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 Note that posts from new members are moderated - please be patient with your

Re: Generation of random sequences

2009-08-25 Thread John Harrop
On Tue, Aug 25, 2009 at 10:42 AM, Fogus wrote: > > A quick and dirty way would be to use a map as your intermediate > storage with your generated numbers as keys and some constant as their > assoc'd value. Once you've populated said map with the proper number > of entries (keeping track of clash

Re: we offer cheap sport shoes men's shoe(www.salegood8.com) casual shoe fashion shoe

2009-08-26 Thread John Harrop
On Tue, Aug 25, 2009 at 11:42 AM, Chouser wrote: > > On Tue, Aug 25, 2009 at 10:36 AM, John Harrop wrote: > > What the hell? > > The group actually gets a steady stream of spam, but it > usually gets deleted instead of being sent to everyone. On > this one I accide

Re: On the reader macro #=

2009-08-26 Thread John Harrop
On Wed, Aug 26, 2009 at 1:13 PM, John Harrop wrote: > This is important to know about for security reasons, also. Specifically, > if you are receiving Clojure data structures in text form over the network, > and don't set *read-eval* to false, you're vulnerable to a "Cl

Re: On the reader macro #=

2009-08-26 Thread John Harrop
This is important to know about for security reasons, also. Specifically, if you are receiving Clojure data structures in text form over the network, and don't set *read-eval* to false, you're vulnerable to a "Clojure injection attack". Someone could send you "(+ 5 #=(System/exit 0))" as a denial-o

Re: Order of keys within a map?

2009-08-27 Thread John Harrop
On Thu, Aug 27, 2009 at 3:35 PM, Howard Lewis Ship wrote: > > Is the order of keys in a map predictable? I have some tests I'm > concerned about, where the keys and values in a map are converted to a > string (ultimately, a URL, as query parameters) and the order will > affect the output string.

Re: Java STM

2009-08-28 Thread John Harrop
On Fri, Aug 28, 2009 at 4:45 AM, peter veentjer wrote: > > Clojure's STM is part of a holistic language design where > > people will normally be programming with immutable persistent > > composite data structures. Getting a consistent view of such a data > > structure doesn't require a transaction

Re: Lazy Exceptions

2009-08-28 Thread John Harrop
On Fri, Aug 28, 2009 at 8:50 AM, Rich Hickey wrote: > > On Thu, Aug 27, 2009 at 8:10 PM, Tim Snyder wrote: > > > > Well, I can see that LazySeq does indeed catch and wrap all Exceptions > > in a RuntimeException. I also think I can work around it, but I'd > > like to know why this was done? > >

Re: Clojure/EPL and the GPL

2009-08-29 Thread John Harrop
This is a problem. The GPL is a very popular open source license. If a language does not permit developers to use the GPL, that language may be severely reducing the number of developers willing to adopt it. It would be desirable for clojure.lang and clojure.core to use a modified license, somethi

Re: Clojure/EPL and the GPL

2009-08-29 Thread John Harrop
On Sat, Aug 29, 2009 at 12:00 PM, Rich Hickey wrote: > > This has been discussed as nauseam before: > > > http://groups.google.com/group/clojure/browse_frm/thread/6e99caafcf2bbedf/b5519cc219a5baeb > > Nothing has changed, so let's give it a rest, please. This may be a tempest in a tea-pot, at l

Re: Clojure/EPL and the GPL

2009-08-30 Thread John Harrop
On Sun, Aug 30, 2009 at 7:57 AM, Jan Rychter wrote: > > Tassilo Horn writes: > [...] > > BTW: What's the reason that Clojure is licensed under the EPL and the > > contrib stuff under CPL? Since clojure is not really eclipse-related, I > > don't see a good rationale. IMHO, the Lesser GPL would

Re: Why am I getting this performance result from Clojure CLR's LispReader?

2009-08-30 Thread John Harrop
On Sun, Aug 30, 2009 at 10:40 AM, Jason Baker wrote: > > I've written a test that does this: > >public void ReadFile(TextReader infile) >{ >using (var text_reader = new PushbackTextReader(infile)) { >LispReader.read(text_reader, false, null, true); >

Re: assoc-in-by

2009-08-30 Thread John Harrop
On Sun, Aug 30, 2009 at 4:14 PM, kyle smith wrote: > > I wrote this based on assoc-in. If anyone thinks this should be in > core or contrib, feel free to use it. > > (defn assoc-in-by > "'Updates' a value in a nested associative structure, where ks is a > sequence of keys and (f v) is the new

Re: vs. Python

2009-08-30 Thread John Harrop
On Sun, Aug 30, 2009 at 12:32 PM, CuppoJava wrote: > > Your examples are very good I think. It always helps to have a > straight-forward conversion from one language to another for > beginners. They will eventually pick up idioms and methodology by > playing around. > > One comparison that bothers

Re: vs. Python

2009-08-31 Thread John Harrop
On Mon, Aug 31, 2009 at 5:15 PM, Brian Hurt wrote: > If I recall correctly (and correct me if I'm wrong), Python uses a > reference counting garbage collector. Which means as soon as the reference > to the object goes away, the object gets collected and the handle closed. > Most JVMs use some fo

Re: vs. Python

2009-08-31 Thread John Harrop
On Mon, Aug 31, 2009 at 5:04 PM, Brian Hurt wrote: > On Sun, Aug 30, 2009 at 9:31 AM, Jason Baker wrote: > >> On Aug 30, 2:24 am, Dan Fichter wrote: >> > The Clojure version is more concise and radically safer but a little >> more >> > conceptually packed. Is it worth your trouble? >> >> Being

Re: A complete documentation (downloadable)

2009-08-31 Thread John Harrop
On Mon, Aug 31, 2009 at 3:45 PM, freddi301 wrote: > > are there a complete clojure documentation ? There's the documentation at clojure.org; you could spider it with wget, though with some sites you need to spoof the user-agent and/or hack wget to disable retrieving robots.txt to do that. (Ethi

Re: Two possible additions: non-reflective classobject calls & support for map-conj on arrays

2009-09-01 Thread John Harrop
On Tue, Sep 1, 2009 at 10:40 AM, Rich Hickey wrote: > On Mon, Aug 31, 2009 at 10:55 AM, Krukow wrote: > > > > I have two minor minor suggestions for Clojure changes. > > > > 1) Consider this function: > > user> (set! *warn-on-reflection* true) > > true > > user> (defn reader-from-classpath [s] >

Re: Filter Causing StackOverflowError?

2009-09-02 Thread John Harrop
On Wed, Sep 2, 2009 at 1:02 PM, tmountain wrote: > > Hi all - I've recently encouraged a friend to start learning Clojure, > and he has written some basic Markov chaining code as a learning > exercise. His code works fine with small sets of input data, but > larger inputs have been causing a Stac

Re: Tight loop performance

2009-09-06 Thread John Harrop
Besides using just aset, try using unchecked-inc instead of inc. --~--~-~--~~~---~--~~ 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 Note that posts from new m

Re: Tight loop performance

2009-09-06 Thread John Harrop
Try unchecked-inc and try wrapping the function body in (let [words (int words)] ... ). I don't know why aset is still reflecting when all of the arguments are type-hinted, but the above changes might speed up some other bits of the code. --~--~-~--~~~---~--~~ You r

Re: dynamic :use

2009-09-07 Thread John Harrop
Or, you can go the opposite way and write a macro that expands into the appropriate ns form. This will work if the information you need from *db-adapter* is there by macroexpansion time. A macro that does a similar job to ns, but adds conditional features to the ns "DSL", can wrap and generalize w

  1   2   3   4   >