Re: Why do Refs implement IFn and Atoms don't?

2009-05-14 Thread Christophe Grand
David Nolen a écrit : > Just curious about the reasoning behind this decision? > > ((ref +) 3 4) ; -> 7 > ((atom +) 3 4) ; Exception Last time I asked, Rich said to not rely on refs implementing IFn. (It may be a remain from the time where vars and refs were the same thing -- just guessing) -

Re: OutOfMemoryError with clojure.contrib.sql and large result sets

2009-05-14 Thread Stephen C. Gilardi
On May 14, 2009, at 7:13 PM, Ian Eure wrote: I'm trying to process mid/large result sets with Clojure, and not having any success. (ns foo (:require [clojure.contrib.sql :as sql])) (def *db* {:classname "com.mysql.jdbc.Driver" :subprotocol "mysql" :subname "//DSN"

Re: Colored parentheses highlighting for Emacs Clojurians

2009-05-14 Thread David Nolen
Cool :) highlight-parentheses.el does this as well, it's just a flag. On Thu, May 14, 2009 at 1:01 PM, Chris Stucchio wrote: > > Very nice. See also hl-sexp, which highlights the entire sexp, rather > than merely the parenthesis. > > http://edward.oconnor.cx/elisp/hl-sexp.el > > On May 13, 5:53

OutOfMemoryError with clojure.contrib.sql and large result sets

2009-05-14 Thread Ian Eure
I'm trying to process mid/large result sets with Clojure, and not having any success. (ns foo (:require [clojure.contrib.sql :as sql])) (def *db* {:classname "com.mysql.jdbc.Driver" :subprotocol "mysql" :subname "//DSN" :user "read" :password "swordf

Re: Colored parentheses highlighting for Emacs Clojurians

2009-05-14 Thread Chris Stucchio
Very nice. See also hl-sexp, which highlights the entire sexp, rather than merely the parenthesis. http://edward.oconnor.cx/elisp/hl-sexp.el On May 13, 5:53 pm, David Nolen wrote: > This works really well:http://nschum.de/src/emacs/highlight-parentheses/ --~--~-~--~~~--

Re: str-utils change proposal, round 2

2009-05-14 Thread Daniel Lyons
> I'm doing the same. I cannot judge the quality of OpenCVS but up to > now I had no problems. I thought about using fnparse to build a > clojure > CSV parser, but I'm not sure how hard this would be. Let's see with > what Stuart comes up. CSV parsing is a headache because there are so many imp

Why do Refs implement IFn and Atoms don't?

2009-05-14 Thread David Nolen
Just curious about the reasoning behind this decision? ((ref +) 3 4) ; -> 7 ((atom +) 3 4) ; Exception --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goog

Re: str-utils change proposal, round 2

2009-05-14 Thread Wilson MacGyver
it sounds like what I'm looking for will be served by Stu's csv parser in clojure. the other need that comes to mind was stripping the annoying Microsoft's "smart quote" characters. ie, replace them with regular quote marks. This came to mind because I saw your string functions have html escapin

Re: Help with Type Hint

2009-05-14 Thread Kevin Downey
so I took a look at with this code: http://gist.github.com/111935 output: :original "Elapsed time: 369.683 msecs" :redux-1 "Elapsed time: 11672.329 msecs" :redux-2 "Elapsed time: 74.233 msecs" as to why there is such a huge difference between your code and redux-2 I am not sure. I would defin

Re: Annotations and gen-class

2009-05-14 Thread Richard Newman
A couple of months late to this discussion, but I thought I'd throw in my 2¢: annotations are pretty important for more things than just filling in deficiencies in Java. For example, SIP Servlets 1.1 — finalized in August 2008 — actively discourages the use of deployment descriptor entries in fav

3D Grapher in Clojure

2009-05-14 Thread Curran Kelleher
Greetings, I have had success writing a 3D graphing program in Clojure, which parses a user defined parametric function (of the form (x,y,z) = f (u,v)) and renders it as a freely rotatable 3D surface (using OpenGL). The full source code is posted here (public domain, feel free to use, copy, etc)

Re: Adding :svn to *clojure-version*

2009-05-14 Thread lazy1
Also at http://paste.lisp.org/display/80244 --~--~-~--~~~---~--~~ 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 email to

Adding :svn to *clojure-version*

2009-05-14 Thread lazy1
Hello All, I think it's a good idea to add the subversion revision to *clojure- version*. The below patch will work once someone does "svn ps svn:keywords Revision core.clj". Index: src/clj/clojure/core.clj === --- src/clj/clojure

Re: Help with Type Hint

2009-05-14 Thread Dimiter "malkia" Stanev
This is the best I was able to come up with in Clojure: (defn byte-array-contains? [coll key] "scans a byte array for a given value" (let [c (int (count coll)) k (byte key)] (loop [i (int 0)] (if (< i c) (if (= k (aget coll i)) true (recur (unchec

Re: Help with Type Hint

2009-05-14 Thread Boris Mizhen - 迷阵
Please correct me if I'm wrong, but my understanding is that Clojure compiler can produce bytecode equivalent to compiled Java code. I think the right approach would be to figure out how to do this in Clojure for the cases like this. Rich? Boris On Thu, May 14, 2009 at 2:25 PM, tmountain wrot

Re: Help with Type Hint

2009-05-14 Thread tmountain
Thanks for all the helpful advice. I may consider rewriting key portions in Java if performance becomes an issue. Travis On May 14, 12:10 pm, David Nolen wrote: > If you're going to do that you're going to need to create a let binding > which type-hints coll to bytes in your byte-array-contains

Re: str-utils change proposal, round 2

2009-05-14 Thread Meikel Brandmeyer
Hi, Am 14.05.2009 um 17:12 schrieb Daniel Lyons: That would be wonderful. I have wrapped OpenCSV for my own purposes but would of course prefer not having another library dependency. My code wound up like this: (import 'java.io.FileReader 'au.com.bytecode.opencsv.CSVReader)) (defn read-csv [

Re: Help with Type Hint

2009-05-14 Thread David Nolen
If you're going to do that you're going to need to create a let binding which type-hints coll to bytes in your byte-array-contains? If you're going to be doing this a lot in your code I'd recommend making a helper class in Java. loop/recur is fast, but for absolute speed, you just can't beat puttin

Re: Help with Type Hint

2009-05-14 Thread tmountain
NM, huge difference in performance even with the cast. Old version: (time (dotimes [_ 1000] (byte-array-contains? header 0xFE))) "Elapsed time: 337.312 msecs" New version: (time (dotimes [_ 1000] (byte-array-contains? header 0xFE))) "Elapsed time: 4.278 msecs" On that note, is there a native

Re: Help with Type Hint

2009-05-14 Thread tmountain
If that's the case, would I even get a performance increase, or would the cast overhead cost more than the implicit reflection? On May 14, 11:32 am, David Nolen wrote: > This baffled me as well. You need to cast to int. > > On Thu, May 14, 2009 at 11:22 AM, tmountain wrote: > > > I'm trying to

Re: Help with Type Hint

2009-05-14 Thread David Nolen
This baffled me as well. You need to cast to int. On Thu, May 14, 2009 at 11:22 AM, tmountain wrote: > > I'm trying to optimize some code I've written, and I have set warn on > reflection as advised. I'm having a hard time getting a simple > statement to avoid reflection. > > user=> (== (byte 0x

Help with Type Hint

2009-05-14 Thread tmountain
I'm trying to optimize some code I've written, and I have set warn on reflection as advised. I'm having a hard time getting a simple statement to avoid reflection. user=> (== (byte 0x1) (byte 0x1)) Reflection warning, line: 33 - call to equiv can't be resolved. Can you use type hints on primitiv

Re: str-utils change proposal, round 2

2009-05-14 Thread Sean Devlin
Hmmm... it sounds like there would be use for a "string table utils" or something like that. On May 14, 11:12 am, Daniel Lyons wrote: > On May 14, 2009, at 7:14 AM, Stuart Halloway wrote: > > > > > FYI: I am working on an open-source CSV parser in Clojure. Splitting > > on delimiters is rarely e

Re: str-utils change proposal, round 2

2009-05-14 Thread Daniel Lyons
On May 14, 2009, at 7:14 AM, Stuart Halloway wrote: > > FYI: I am working on an open-source CSV parser in Clojure. Splitting > on delimiters is rarely enough in my experience. That would be wonderful. I have wrapped OpenCSV for my own purposes but would of course prefer not having another li

Re: tree-utils

2009-05-14 Thread Jarkko Oranen
> Recursively summing all the elements in a tree: > user=>(tree-apply #(reduce + %) true true atree) > 28 > user=>(tree-apply #(reduce + %) true true btree) > 34 > > I think these are generally useful, so I'm just looking for some > feedback and possible inclusion in contrib.  Thanks! Please do

Re: str-utils change proposal, round 2

2009-05-14 Thread Sean Devlin
Stuart, Excellent point about delimiters, parsing CSV is much more sophisticated than my simple s-exp. However, since you're writing a parser you've worked with strings a lot :) I use something like str-take/str-drop all the time in my parsers. So if you could answer a few questions... 1. Wo

Re: str-utils change proposal, round 2

2009-05-14 Thread Stuart Halloway
FYI: I am working on an open-source CSV parser in Clojure. Splitting on delimiters is rarely enough in my experience. Stu > would you consider adding support of a split by passing a delimiter? > since parsing csv/tsv is a pretty common task. > > I know it can be done by using re-split. but it

Re: str-utils change proposal, round 2

2009-05-14 Thread Sean Devlin
I guess I don't quite see what you're asking for. If I understand you right, here's how I would do your task today: (def input-string (slurp "My File.csv")) ;And using my re-split fn... (re-split input-string '(#"[\r\n]" #",")) This would return a list of rows & cols, and could then be manipu

Re: Concerns About Pushing Clojure 1.0.0 to Maven Central Repo?

2009-05-14 Thread Rich Hickey
On Tue, May 12, 2009 at 5:36 PM, Laurent PETIT wrote: > Hello, > > It seems that it's really a matter of convention, I don't see any technical > problem of having a groupId of org.clojure and an artifactId of clojure. > > Please let me try to summarize this never ending discussion: > > Currently

"splitting" sql results by attribute

2009-05-14 Thread Michael Glaesemann
Hello! I'm new to clojure and new to lisp, so I'm still getting accustomed to working functionally and I'm trying to take advantage of clojure's sequences when appropriate. I'm working on a project to display a variety of measurements and comparing values across various intervals. I'm pull

Re: Extending clojure.contrib.json.write/print-json

2009-05-14 Thread Josip Gracin
On Thu, May 14, 2009 at 1:57 AM, Stuart Sierra wrote: > The latest version of c.c.json dispatches on the "type" function, > which in turn uses "class."  It should be pretty easily extendible. Thanks! -- mr.sc. Josip Gracin, dipl.ing. direktor razvoja Inge-mark d.o.o., Zavrtnica 17, Zagreb tel:

Re: tree-utils

2009-05-14 Thread Konrad Hinsen
On 14.05.2009, at 09:22, Laurent PETIT wrote: > Isn't tree-reduce similar to clojure.contrib.generic.functor/fmap > (though fmap preserves the type of the structure, while your > function returns seqs of seqs ...) ? fmap is not recursive. When given a list, it would only act at the top lev

Re: tree-utils

2009-05-14 Thread Laurent PETIT
Hi, Isn't tree-reduce similar to clojure.contrib.generic.functor/fmap (though fmap preserves the type of the structure, while your function returns seqs of seqs ...) ? (Ah, and I find that the name reduce here is a bit misleading, since the operation really does a mapping from a tree to another ?

Re: str-utils change proposal, round 2

2009-05-14 Thread Wilson MacGyver
would you consider adding support of a split by passing a delimiter? since parsing csv/tsv is a pretty common task. I know it can be done by using re-split. but it seems to occur common enough that it's not a bad idea. On Thu, May 14, 2009 at 1:12 AM, Sean Devlin wrote: > > Hello again everyone