How to efficiently import large array of doubles from file?

2010-02-22 Thread Johann Kraus
Hi everyone, I need some help for loading in large data from file. For instance, I'm trying to load from a text file one line of 5000 double values (separated by comma). Having 8 byte per double I would assume this to fit into ~400MB of memory, at least when using a java double array internall

Re: Newbie suggestion for an implementation - rosettacode pythagorean means

2010-02-22 Thread Johnny Kwan
Hi, On Feb 22, 2010, at 1:43 AM, Meikel Brandmeyer wrote: > Hi, > > On Feb 22, 12:18 am, Johnny Kwan wrote: >> I'm really new to Clojure, but I'm under the impression that reduce would >> be better than apply, since I assume that apply would reify the entire >> sequence at once, whereas reduce

Re: Testing Private Functions

2010-02-22 Thread Johnny Kwan
Hi, On Feb 22, 2010, at 2:20 AM, Meikel Brandmeyer wrote: > First some fixes: > > (defmacro #^{:private true} use-private > [ns sym] > `(def ~(with-meta sym {:private true}) @(ns-resolve '~ns '~sym))) Awesome! >> This, however, doesn't work. The first ~sym macroexpands to (quote sym), >> w

Re: Testing Private Functions

2010-02-22 Thread Meikel Brandmeyer
Hi, On Feb 22, 11:55 am, Johnny Kwan wrote: > You're absolutely right.  I use 'ns and 'sym because that's what all of the > ns- functions use.  I realize now that this is a macro, not a fn...  :)  I > would like to make the fact that this is a macro transparent, so that it only > accepts symb

Re: Newbie suggestion for an implementation - rosettacode pythagorean means

2010-02-22 Thread Meikel Brandmeyer
Hi, On Feb 22, 11:43 am, Johnny Kwan wrote: > (time (reduce + (range 1 1000))) ; 4.5 secs on my Macbook Air > (time (apply + (range 1 1000))) ; OutOfMemory error Ah. It holds unto the head. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups

Re: Newbie suggestion for an implementation - rosettacode pythagorean means

2010-02-22 Thread Michael Kohl
On Mon, Feb 22, 2010 at 11:43 AM, Johnny Kwan wrote: > Whichever is faster depends on the size of the argument list I see, thanks for clarifying. I'd then change my version to this since I still like map with an anonymous function more than the for-comprehension in this case. defn h-mean [coll]

defalias semantics changed in 1.2: bug?

2010-02-22 Thread Stuart Halloway
With 1.1 you could defalias a macro: (defmacro foo) (defalias bar foo) With 1.2, the {:macro true} gets set to {:macro false}, so bar isn't a macro. I spent a few minutes and couldn't find the change that caused this. I like the 1.1 behavior better. Anybody know the story on how this cha

Re: generalize distinct

2010-02-22 Thread Eugen Dueck
Yes, for the reasons stated. First, and most important, clojure.core/distinct does not let me pass in a keyfn, it's hard-coded. Second, and as mentioned that's debatable, distinct could make more of the filtering functionality it already has available to the caller, for free. On Feb 22, 11:53 am

Re: generalize distinct

2010-02-22 Thread Sean Devlin
It sounds to me that you want to use c.c.seq-utils/group-by, not distinct. On Feb 22, 7:22 am, Eugen Dueck wrote: > Yes, for the reasons stated. > > First, and most important, clojure.core/distinct does not let me pass > in a keyfn, it's hard-coded. > > Second, and as mentioned that's debatable,

Re: How to efficiently import large array of doubles from file?

2010-02-22 Thread John Williams
The overhead of using a Clojure vector will be a little more than 2.5x on a 32-bit Sun JVM, because each Java object has an 8-byte overhead, and storing references to those objects in a Clojure vector will use just over 4 bytes per object. I'm not sure what the figure would be for a 64-bit JVM, bu

Re: How to efficiently import large array of doubles from file?

2010-02-22 Thread David Nolen
On Mon, Feb 22, 2010 at 5:30 AM, Johann Kraus wrote: > However, when loading with read-lines from > clojure.contrib.duck-streams and (map #(Double/parseDouble %) (.split > line ",")) clojure requires several GB of RAM. Any suggestions for how > to get this down to 400MB? And what would be the over

add-classpath replacement

2010-02-22 Thread Lukas Lehner
Hi all add-classpath is marked as depreciated and does not work :( (add-classpath "file:///jars/icu4j-4_2_1.jar") Context classloader is not a DynamicClassLoader [Thrown class java.lang.IllegalAccessError] I don't want to restart jvm anytime I need a new jar. Any workaround or replacement?

Re: How to efficiently import large array of doubles from file?

2010-02-22 Thread Johnny Kwan
Hi, On Feb 22, 2010, at 9:39 AM, David Nolen wrote: You also might want to pick a different strategy for parsing the string instead of splitting the string immediately into 5000 parts. Along those lines, just use a regexp sequence. Thanks, Johnny -- You received this message because

Re: How to efficiently import large array of doubles from file?

2010-02-22 Thread Krešimir Šojat
Hi, On Feb 22, 11:30 am, Johann Kraus wrote: > However, when loading with read-lines from > clojure.contrib.duck-streams and (map #(Double/parseDouble %) (.split > line ",")) clojure requires several GB of RAM. In this case (as your numbers are delimited with ",") read-lines will read just one g

First Atlanta Function Programming Users Group Meeting

2010-02-22 Thread David Vollbracht
For any functional programmers in or around Atlanta, GA, The Atlanta Functional Programming Users Group is having its first Meeting! Although the talk at this meeting will be about Haskell, we welcome users of all functional programming languages and would love to have Clojure users represented i

Re: generalize distinct

2010-02-22 Thread Eugen Dück
group-by does not filter, in contrast to distinct. And I'm really only interested in one of the values considered equal according to my keyfn. So if I sed group-by, I'd have to wrap it with a call to map or similar. This is certainly an option, but I'd rather not create all the intermediate vector

Re: Montreal Clojure User Group

2010-02-22 Thread Jeff Heon
Coffee sounds great. I'm from the suburbs, but I work downtown. Maybe even a lunch would be feasible. Not to pollute the Clojure group, I set up a temporary blog for us : http://mcug.blogspot.com/ On Feb 21, 11:20 pm, Dan wrote: > Should we go for a coffee to meet each other or something? --

Re: add-classpath replacement

2010-02-22 Thread David Nolen
On Mon, Feb 22, 2010 at 11:20 AM, Lukas Lehner wrote: > I don't want to restart jvm anytime I need a new jar. > Any workaround or replacement? > This is one of the real downsides of the JVM. But it does beg the question, why do you need to add jars constantly to your REPL? add-classpath was neve

Re: Montreal Clojure User Group

2010-02-22 Thread Nicolas Buduroi
I've accepted the invitation to the Blog. Still, I don't think it could replace a discussion group or mailing list. I wonder what means other groups or using to coordinate their meeting? On Feb 22, 12:09 pm, Jeff Heon wrote: > Coffee sounds great. > > I'm from the suburbs, but I work downtown. >

Re: Do I need to add "dosync" when I read the ref in this case

2010-02-22 Thread Michał Marczyk
On 21 February 2010 16:49, Jack Fang wrote: > So I can guess that, If you use deref, there can be multipule > transcation running at once. But sometimes transcation must be rerun. > If you use ensure, only one transcation is run. Others are blocked. > Is it true? Those which try to modify the ref

Re: Do I need to add "dosync" when I read the ref in this case

2010-02-22 Thread Michał Marczyk
On 21 February 2010 20:58, Michael Wood wrote: > Ah yes, that makes more sense :) Yes, the first version I've posted was written precisely so as to obscure my point. :-) >> I'm using a newer commit (49a7d6b8e14050a45df5332e768ba6647752215d), >> but this shouldn't make any difference. > > No, I o

Re: generalize distinct

2010-02-22 Thread Michał Marczyk
The Haskell approach is to have two functions, nub and nubBy, which perform the task of distinct and the task of distinct with a user-provided keyfn, respectively. I'd love to see a distinct-by in core or contrib. (Mostly for completeness, it's easy enough to write...) As for the extra set argumen

Re: generalize distinct

2010-02-22 Thread Sean Devlin
What does distinct-by return in case of a collision? (keys (group-by...)) (map first (vals (group-by ...))) (map other-fn (vals (group-by ...))) You're still better off w/ group-by, and manipulating the resulting map appropriately. Sean On Feb 22, 1:15 pm, Michał Marczyk wrote: > The Haskell

Re: generalize distinct

2010-02-22 Thread Michał Marczyk
On 22 February 2010 19:25, Sean Devlin wrote: > What does distinct-by return in case of a collision? I'm not sure what you mean by that. distinct-by would do precisely what distinct does, only instead of comparing the items of the argument collection themselves, it would compare values of (keyfn

Re: generalize distinct

2010-02-22 Thread Michał Marczyk
My apologies for misrepresenting Haskell's nubBy: On 22 February 2010 19:15, Michał Marczyk wrote: > The Haskell approach is to have two functions, nub and nubBy, which > perform the task of distinct and the task of distinct with a > user-provided keyfn, respectively. Actually nubBy takes a bina

Re: generalize distinct

2010-02-22 Thread Michał Marczyk
PS. The code for both functions is lifted straight from clojure.core's distinct. -- 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 p

Re: generalize distinct

2010-02-22 Thread Sean Devlin
Generally when you have a "*-by" fn, you return the a sequence of original values, not the mapped values (e.g. sort-by) However, in the case you suggest, you really should just be using map & distinct, and not creating your own fn. Using the built ins as much as possible is more idiomatic Clojure

Re: Testing Private Functions

2010-02-22 Thread Alan Dipert
Hi, This is a problem I was working on this morning (with the help of chouser, thank you!), and ended up with a 'with-private-fns' macro that works like this: (with-private-fns [org.foo.bar [fn1 fn2]] (deftest test-fn1..) (deftest test-fn2..)) I'm a Clojure greenhorn, but I like this approach

appropriate uses of clojure

2010-02-22 Thread strattonbrazil
Object-oriented design has been frequently sourced as becoming standard for simulations. Even on the clojure website, it states, "[Object-oriented design is ] Born of simulation, now used for everything, even when inappropriate". I've also heard GUIs are more easily developed using object orienta

feedback on modified clojure.test.are macro

2010-02-22 Thread Dan Becker
(Moderators ... resending this, sorry if it's already in the queue) Hi, I'd like to be able to use the *are* testing macro like this: (are [input] (= input (myfun input)) *my-input-data*) But this doesn't work; the args are expected to be listed on-by-one, not in a list: (defmacro are [ar

Re: generalize distinct

2010-02-22 Thread Michał Marczyk
On 22 February 2010 19:59, Sean Devlin wrote: > Generally when you have a "*-by" fn, you return the a sequence of > original values, not the mapped values (e.g. sort-by) Which is precisely what both versions of distinct-by are doing. They return a sequence of values taken from the original collec

Re: generalize distinct

2010-02-22 Thread Sean Devlin
Okay, your longer post makes more sense. Then is the seq (1 :a a) guaranteed? How do I know that I won't get (2 :b b), (1 :b c), etc? What if I want a specific combination instead? I've had to actually code this specific problem, and I found that using group-by & some secondary mapping operatio

practical compilation question

2010-02-22 Thread Robert McIntyre
Has anyone successfully gotten clojure to play well with eclipse in developing java code? By this I mean that the clojure code automatically compiles to class files the same way as java files in eclipse do, and the whole thing can then be packaged into a jar and made into a web start application?

Re: appropriate uses of clojure

2010-02-22 Thread Stuart Halloway
It will be difficult to find the review you are looking for, because (IMO) Clojure is gradually carving out its own ecological niche. For example, is Stuart Sierra's recent draft of test2 (http://paste.lisp.org/display/95188#1 ) FP, or is it OO? You could make the case that this style of pr

Re: defalias semantics changed in 1.2: bug?

2010-02-22 Thread Michael Wood
On 22 February 2010 15:43, Stuart Halloway wrote: > With 1.1 you could defalias a macro: > > (defmacro foo) > (defalias bar foo) > > With 1.2, the {:macro true} gets set to {:macro false}, so bar isn't a > macro. I spent a few minutes and couldn't find the change that caused this. > > I like the 1

Re: add-classpath replacement

2010-02-22 Thread Meikel Brandmeyer
Hi, On Mon, Feb 22, 2010 at 05:20:07PM +0100, Lukas Lehner wrote: > add-classpath is marked as depreciated and does not work :( > > (add-classpath "file:///jars/icu4j-4_2_1.jar") > > Context classloader is not a DynamicClassLoader > [Thrown class java.lang.IllegalAccessError] > > I don't wan

Re: practical compilation question

2010-02-22 Thread Laurent PETIT
Hello, 2010/2/22 Robert McIntyre : > Has anyone successfully gotten clojure to play well with eclipse in > developing java code? > > By this I mean that the clojure code automatically compiles to class > files the same way as java files in eclipse do, and the whole thing > can then be packaged int

Re: Newbie suggestion for an implementation - rosettacode pythagorean means

2010-02-22 Thread Aviad Reich
I don't mean to signal the end of this thread, but I just wanted to thank you all for you replies. I will update the draft (and add Colin and Mikel's infinite seq code as well) possible in a day or two (no at home till then), and post the new code before posting to Rosetta. Cheers, Aviad On 22 F

Re: generalize distinct

2010-02-22 Thread Michał Marczyk
On 22 February 2010 20:28, Sean Devlin wrote: > Then is the seq (1 :a a) guaranteed?  How do I know that I won't get > (2 :b b), (1 :b c), etc?  What if I want a specific combination > instead?  I've had to actually code this specific problem, and I found > that using group-by & some secondary map

Re: Testing Private Functions

2010-02-22 Thread Meikel Brandmeyer
Hi, On Mon, Feb 22, 2010 at 02:04:37PM -0500, Alan Dipert wrote: > (defmacro with-private-fns [[ns fns] & tests] > "Refers private fns from ns and runs tests in context." > `(let ~(reduce #(conj %1 %2 `(ns-resolve '~ns '~%2)) [] fns) > ~...@tests)) Without a deref around the ns-re

Re: generalize distinct

2010-02-22 Thread Sean Devlin
Excellent points. +1 for orthogonality. Sean On Feb 22, 3:13 pm, Michał Marczyk wrote: > On 22 February 2010 20:28, Sean Devlin wrote: > > > Then is the seq (1 :a a) guaranteed?  How do I know that I won't get > > (2 :b b), (1 :b c), etc?  What if I want a specific combination > > instead?  I'

Re: add-classpath replacement

2010-02-22 Thread Lukas Lehner
Hi For that I need to run JVM again... Imagine I am using one VM instance for more in parallel running programs and updating them as they are running. When I shutdown VM, I have to start and set up all of them again. (I cannot get the desired state of environment so quickly) L On 2/22/201

Re: add-classpath replacement

2010-02-22 Thread Lukas Lehner
Hi There are some links on google for "java add classpath runtime" Particularly http://jimlife.wordpress.com/2007/12/19/java-adding-new-classpath-at-runtime/ and http://forums.sun.com/thread.jspa?threadID=300557 but haven't tried (not so skilled in java) and don't know how to turn them into c

Re: defalias semantics changed in 1.2: bug?

2010-02-22 Thread Stuart Halloway
Nice git fu! With that help, here is a Clojure-only (no contrib.def) sequence that shows the difference between 1.1 and 1.2: ;; all running on 1.2, DIFF noted in comments (defmacro foo []) -> #'user/foo (meta (def bar (.getRoot #'foo))) -> {:macro false, :ns #, :name bar, :file "NO_SOURCE_P

Re: Emacs/Slime -- Slime wont eval but *inferior-lisp* will (Help a newbie out)

2010-02-22 Thread ajazz
hello, I had the same problem. I created ~/.swank-clojure directory, and downloaded there swank- clojure-1.1.0.jar from http://repo.technomancy.us/. Now M-x slime works. On Feb 20, 11:40 am, Paul Tarvydas wrote: > > >When you perform the installation, you will see warnings related to the > > >

Why the implicit do in forms like let?

2010-02-22 Thread Peter T
Hi all, Disclaimer: absolute beginner here, so probably missing something very obvious. I'm just wondering why certain forms, like let, natively allow for multiple body/expression argument forms. That is, let seems to natively allow for side effects. Wouldn't it make sense to limit let to a sing

Re: add-classpath replacement

2010-02-22 Thread Meikel Brandmeyer
Hi, On Mon, Feb 22, 2010 at 10:25:23PM +0100, Lukas Lehner wrote: > For that I need to run JVM again... Not for the unzipping approach… (at least for adding to the classpath, however not for modifying existing things) > Imagine I am using one VM instance for more in parallel running > programs

Re: Why the implicit do in forms like let?

2010-02-22 Thread Raoul Duke
On Mon, Feb 22, 2010 at 12:51 PM, Peter T wrote: > Am just curious what the rationale is behind the implicit do. ja, personally i find the implicit do's in Clojure or begin's in Schemes to be kinda bad, sort of along the lines of what you say. i feel like there's all this talk about how functiona

Re: Testing Private Functions

2010-02-22 Thread Alan Dipert
Hi Meikel, thank you as always for your help! This makes a lot of sense. Am I correct in understanding that at some level there is a separation of var and fn namespace? Or is the need for deref more just a consequence of the way objects respond with their contents? Please forgive my ignorance,

Re: Why the implicit do in forms like let?

2010-02-22 Thread David Nolen
On Mon, Feb 22, 2010 at 3:51 PM, Peter T wrote: > Hi all, > > Wouldn't it make sense to limit let to a single body/expression > argument, and otherwise require the explicit use of do? > > I realize that'd be rather verbose, but it'd seem to also help make > the presence of side effects more app

Re: Why the implicit do in forms like let?

2010-02-22 Thread David Nolen
On Mon, Feb 22, 2010 at 4:54 PM, Raoul Duke wrote: > On Mon, Feb 22, 2010 at 12:51 PM, Peter T wrote: > > Am just curious what the rationale is behind the implicit do. > > ja, personally i find the implicit do's in Clojure or begin's in > Schemes to be kinda bad, sort of along the lines of what

Re: Why the implicit do in forms like let?

2010-02-22 Thread Raoul Duke
> I think pretty well covered here: http://clojure.org/special_forms. thanks, i'll re-re-read :) -- 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 modera

Redesigning ClojureQL's Frontend

2010-02-22 Thread Nicolas Buduroi
As most of you already probably know, there's a big rework of ClojureQL's frontend. The development is now more focused on this redesign and lots of great ideas have been found. Yet, it's always good to get more inputs as this library will certainly become a common tools for all Clojurians. The cod

Re: Testing Private Functions

2010-02-22 Thread Meikel Brandmeyer
Hi, On Mon, Feb 22, 2010 at 05:07:33PM -0500, Alan Dipert wrote: > Hi Meikel, thank you as always for your help! You are welcome. :) > This makes a lot of sense. Am I correct in understanding that at some > level there is a separation of var and fn namespace? Or is the need > for deref more just

Re: Testing Private Functions

2010-02-22 Thread Alan Dipert
I get it, thank you! Alan Excerpts from Meikel Brandmeyer's message of 2010-02-22 17:22:19 -0500: > Hi, > > On Mon, Feb 22, 2010 at 05:07:33PM -0500, Alan Dipert wrote: > > Hi Meikel, thank you as always for your help! > > You are welcome. :) > > > This makes a lot of sense. Am I correct in und

Re: Montreal Clojure User Group

2010-02-22 Thread Jeff Heon
Okay, Google created: http://groups.google.ca/group/montreal-clojure-user-group -- 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 p

Re: defalias semantics changed in 1.2: bug?

2010-02-22 Thread Michał Marczyk
I've been trying to pinpoint the source of the problem and I found something pretty amazing: Regular def: user> (def foobar (.getRoot #'defalias)) #'user/foobar user> (meta #'foobar) {:ns #, :name foobar, :file "NO_SOURCE_FILE", :line 1} def occuring as an argument to a function: user> (println

Re: http-agent usage in subsequent agent action question

2010-02-22 Thread sim
Hi Tim, On Feb 19, 3:17 pm, Timothy Pratley wrote: > (defn some-action [x] (println "FOO:" (:clojure.contrib.http.agent/result x))) Thanks for the tip, when I looked at the http-agent code and I saw the ::result keyword I thought that meant it was private to the namespace which meant I couldn't

Re: Emacs/Slime -- Slime wont eval but *inferior-lisp* will (Help a newbie out)

2010-02-22 Thread joseph hirn
Thank you brother. This did the trick for me. On Feb 22, 2:39 pm, ajazz wrote: > hello, > I had the same problem. > > I created ~/.swank-clojure directory, and downloaded there swank- > clojure-1.1.0.jar fromhttp://repo.technomancy.us/. Now M-x slime > works. > > On Feb 20, 11:40 am, Paul Tarvyda

Re: Emacs/Slime -- Slime wont eval but *inferior-lisp* will (Help a newbie out)

2010-02-22 Thread joseph hirn
Hi phil. Thanks for your help with this. This step of downloading the jars into .swank-clojure is what never happened and why it never worked through elpa. Downloading the swank-clojure jar manually fixed the problem. I'm not sure if you manage the swank-clojure install via elpa but please let me

Re: Why the implicit do in forms like let?

2010-02-22 Thread James Reeves
On Feb 22, 8:51 pm, Peter T wrote: > I'm just wondering why certain forms, like let, natively allow for > multiple body/expression argument forms. That is, let seems to > natively allow for side effects. Well, firstly, limiting the body of let to one expression doesn't prevent side-effects. Seco