Re: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-27 Thread John Harrop
On Tue, Oct 27, 2009 at 2:33 PM, Emeka wrote: > John, > > That is why I asked that question because I figured out that the problem > has nothing to do with Vector but with #() read macro. I wanted to correct > the impression that the problem was from Vector. That was correct. I just wanted to a

Re: invoking macros from Java

2009-10-27 Thread Alex Osborne
Jeff Brown wrote: > I can invoke a function using Java code that looks something like this... > > Reader reader = new FileReader("clj/demo.clj"); > Compiler.load(reader); > Var var = RT.var("demo", "add_numbers"); > Object result = var.invoke(4, 7); > System.out.println("Result: " + result); >

invoking macros from Java

2009-10-27 Thread Jeff Brown
If I have something like this... (ns demo) (defn add_numbers ([x] x) ([x & rest-args] (reduce + (cons x rest-args (defmacro silly_adder [sum] (let [addend# (for [i (range sum)] 1)] `(add_numbers ~...@addend#))) (defmacro even_sillier_adder [sum] `(silly_adder ~(+ sum 5))) I

Re: take-nth

2009-10-27 Thread Josh Daghlian
The docs could use clarification, but it looks like take-nth is doing what's advertised. Is there ever a case (I can't think of one) where a programmer really wants to feed this function a non-positive n? That is, should take-nth crap out if (< n 1)? --josh On Oct 27, 5:26 pm, Timothy Pratley w

Re: take-nth

2009-10-27 Thread Timothy Pratley
Oh that is confusing! nth indexes from 0 where-as take-nth indexes from 1. The doc string could be considered misleading, as it says that take- nth makes a sequence of "nth" items, but clearly it does not: clojure.core/take-nth ([n coll]) Returns a lazy seq of every nth item in coll. user=> (ta

take-nth

2009-10-27 Thread alxtoth
Hi, Started tinkering with Clojure, and wonderring why (take-nth 0 (range 10)) returns an infinite sequence .. Is this really the expected behaviour? ; ;code bellow is public domain ; (defn take-nth-proposal "Returns a lazy seq of every nth item in coll . Or nil if n less than 1." [n coll]

Re: reading a range from a large file

2009-10-27 Thread Roberto Mannai
setLineNumber should not skip lines (at least officially - see http://java.sun.com/j2se/1.4.2/docs/api/java/io/LineNumberReader.html). If every line is of fixed size, in Java you could use a RandomAccessFile. On Sun, Oct 25, 2009 at 3:30 AM, tommy c wrote: > > I have a huge file(>900MB) that I

Re: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-27 Thread Emeka
John, That is why I asked that question because I figured out that the problem has nothing to do with Vector but with #() read macro. I wanted to correct the impression that the problem was from Vector. Regards, Emeka --~--~-~--~~~---~--~~ You received this messag

Re: reading a range from a large file

2009-10-27 Thread Emeka
> > (with-open [#^Reader r (reader "FILE")] > (with-open [lr (java.io.LineNumberReader. r)] > (.setLineNumber lr 5) > ;; Your code here. > ))) > > Can't the below work? (with-open [#^Reader r (reader "FILE")][lr (java.io.LineNumberReader. r)] ( Regards, Emeka --~--~

Re: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-27 Thread John Harrop
On Tue, Oct 27, 2009 at 2:17 PM, Emeka wrote: > John, > On Tue, Oct 27, 2009 at 6:10 PM, John Harrop wrote: > >> On Tue, Oct 27, 2009 at 1:39 PM, Emeka wrote: >> >>> On Sun, Oct 25, 2009 at 4:57 PM, MarkSwanson >>> wrote: >>> Hello, Someone recently posed the question: (why

Re: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-27 Thread Emeka
John, On Tue, Oct 27, 2009 at 6:10 PM, John Harrop wrote: > On Tue, Oct 27, 2009 at 1:39 PM, Emeka wrote: > >> On Sun, Oct 25, 2009 at 4:57 PM, MarkSwanson >> wrote: >> >>> >>> Hello, >>> >>> Someone recently posed the question: (why doesn't this work) >>> (into {} (map #([% (* % %)]) [1 2 3 4

Re: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-27 Thread John Harrop
On Tue, Oct 27, 2009 at 1:39 PM, Emeka wrote: > On Sun, Oct 25, 2009 at 4:57 PM, MarkSwanson wrote: > >> >> Hello, >> >> Someone recently posed the question: (why doesn't this work) >> (into {} (map #([% (* % %)]) [1 2 3 4])) >> >> > Is this actually a Vector problem or the limitation of the anon

Re: feedback on this code

2009-10-27 Thread eyeris
Or you can stick (sku, quantity) pairs in a cookie. However, personally I prefer sessions. On Oct 27, 9:54 am, Robert Campbell wrote: > Wow, thank you very much. That's definitely a lot simpler. I'm going > to try reimplementing it via your suggestions and see how it goes. > > I like your idea

Re: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-27 Thread Emeka
On Sun, Oct 25, 2009 at 4:57 PM, MarkSwanson wrote: > > Hello, > > Someone recently posed the question: (why doesn't this work) > (into {} (map #([% (* % %)]) [1 2 3 4])) > > Is this actually a Vector problem or the limitation of the anonymous function? Regards, Emeka > (reference: > http://gro

Re: Scientific computing

2009-10-27 Thread Rock
Good question. Let's see. Now, nested vectors ... I don't like them too much for these things. Why? Because they're just that: nested vectors. They're not truly multidimensional vectors, and the more I think about them, the more they really suck from that point of view. For instance, first of all

Is it time to move the mailing list off of Google Groups?

2009-10-27 Thread Howard Lewis Ship
John Resig (the guy behind jQuery) thinks so: http://ejohn.org/blog/google-groups-is-dead/ I've noticed some amount of spam creeping into this list ... the question is how much effort is being put into moderating out that spam. John notes that GG has some gaping holes in it ... very easy to spo

Re: Scientific computing

2009-10-27 Thread Konrad Hinsen
On 27.10.2009, at 17:46, Rock wrote: > What if we created a structmap (a sort of class), where we have a > flattened out one-dimensional clojure vector containing all the data > of our potentially multidimensional (rank n) array, together with its > dimensions and possibly other info? I believe t

Re: Scientific computing

2009-10-27 Thread Rock
But then again ... Thinking this over, one idea that comes to mind: What if we created a structmap (a sort of class), where we have a flattened out one-dimensional clojure vector containing all the data of our potentially multidimensional (rank n) array, together with its dimensions and possibly

Re: add-watch's functions' first argument

2009-10-27 Thread Stuart Sierra
On Oct 26, 5:18 pm, samppi wrote: > Well, that's how the key itself is useful. What I'm wondering is why > it is useful for the key to be passed to the watching function every > time it's called. I suppose you could use the same watching function with different keys for different behavior. -SS

Re: KeyTest$_init_307.class vs KeyTest_init?

2009-10-27 Thread Gorsal
Thx. That should work:) --~--~-~--~~~---~--~~ 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

Re: feedback on this code

2009-10-27 Thread Robert Campbell
Wow, thank you very much. That's definitely a lot simpler. I'm going to try reimplementing it via your suggestions and see how it goes. I like your idea about not maintaining cart state on the server, because it would make my functions easier to test and debug (no need to setup & teardown a fake

clojure@googlegroups.com

2009-10-27 Thread Chouser
On Tue, Oct 27, 2009 at 1:01 AM, Cristian wrote: > > I tried overloading -init, but I get the same problem. > > java.lang.ClassFormatError: Duplicate field name&signature in class > file test/gui/button (repl-1:2) > > e.g.: > > (ns test.gui.button >  (:gen-class >   :extends javax.swing.JButton >

Re: KeyTest$_init_307.class vs KeyTest_init?

2009-10-27 Thread Meikel Brandmeyer
Hi, Am 27.10.2009 um 04:18 schrieb Gorsal: > I guess this is a very similar error to the one above mentioned. I > guess i sort of nested ns again. Do you have any suggestions for > preventing name clashing of the functions? Use gensym: (defmacro new-handler-class [classname-sym event & body]

Re: doseq destructuring - weird behaviour

2009-10-27 Thread Abhijith
On Oct 27, 12:24 am, Meikel Brandmeyer wrote: > Hi, > > Am 26.10.2009 um 18:55 schrieb Abhijith: > > > (defn foobar [arr--of-arr] > >  (let [ acc (transient {}) ] > >    (doseq [ [i e] (indexed arr-of-arr) word e ] > >      (assoc! acc word (if-let [v (acc word)] (conj v i) [i]))) > >    (persist

clojure@googlegroups.com

2009-10-27 Thread Cristian
I tried overloading -init, but I get the same problem. java.lang.ClassFormatError: Duplicate field name&signature in class file test/gui/button (repl-1:2) e.g.: (ns test.gui.button (:gen-class :extends javax.swing.JButton :constructors {[] [String]} :init init)) (defn -init ([] [[

Re: doseq destructuring - weird behaviour

2009-10-27 Thread Abhijith
> You nailed it.  It's not about destructuring, it's using doseq to > "bash in place" a transient collection.  You won't get correct > results unless you take the return value of 'assoc!' as your new > collection.  Even though most of the time it will return the same > transient you passed in with

Re: Measuring code complexity

2009-10-27 Thread John Harrop
On Mon, Oct 26, 2009 at 6:09 PM, kyle smith wrote: > Rather than the number of nodes in a tree, I think a better metric > would be the number of edges in a graph. Variables that are > referenced on many different lines should get double counted. I think > this would explain why imperative spagh

Re: KeyTest$_init_307.class vs KeyTest_init?

2009-10-27 Thread John Harrop
On Mon, Oct 26, 2009 at 11:18 PM, Gorsal wrote: > Again, there is compiled something like ns_name__154__auto__ > $init__162.class. I really wonder what these dollar signs signify! Nested classes are indicated that way at the JVM level. --~--~-~--~~~---~--~~ You

Re: feedback on this code

2009-10-27 Thread Timothy Pratley
Hi Robert On Oct 27, 9:48 pm, Robert Campbell wrote: > Hey guys, I'm looking for _any_ feedback/thoughts on this Clojure code > I wrote. I just feel like the entire thing is way too complex, but I'm > not sure about how to simplify it. I wanted to try something "real > world" so I made a simple

feedback on this code

2009-10-27 Thread Robert Campbell
Hey guys, I'm looking for _any_ feedback/thoughts on this Clojure code I wrote. I just feel like the entire thing is way too complex, but I'm not sure about how to simplify it. I wanted to try something "real world" so I made a simple shopping cart ref to put in a session: (defstruct cart :line-