Re: puzzlement over lazy sequences

2011-09-13 Thread Michael Gardner
On Sep 12, 2011, at 11:28 PM, Ken Wesson wrote: But if, as you say, take, drop, etc. work for larger n, it should be easy to make nth work with larger n and non-random-access seqs, just by changing the non-random-access case to (first (drop n the-seq)). I'd be rather surprised if nth suddenly

Re: puzzlement over lazy sequences

2011-09-13 Thread Ken Wesson
On Tue, Sep 13, 2011 at 2:39 AM, Michael Gardner gardne...@gmail.com wrote: On Sep 12, 2011, at 11:28 PM, Ken Wesson wrote: But if, as you say, take, drop, etc. work for larger n, it should be easy to make nth work with larger n and non-random-access seqs, just by changing the

Re: puzzlement over lazy sequences

2011-09-13 Thread Stefan Kamphausen
Hi, On Tuesday, September 13, 2011 6:28:01 AM UTC+2, Ken Wesson wrote: They're trees of arrays of 32 items, and the trees can in principle have arbitrary depth. So the 2^31 limit on Java arrays doesn't impact the Clojure collections, it seems. are you sure? As far as I understood things

good ways to deal with compiler errors in SLIME (emacs)

2011-09-13 Thread Sergey Didenko
Hi, How can I see the error line number in SLIME? Or even somehow place editor point on the place of the error? For example when I load file in a lein repl, it prints: java.lang.Exception: Unable to resolve symbol: dd in this context (mytest.clj:447) However when I load this file in the SLIME

Re: puzzlement over lazy sequences

2011-09-13 Thread Ken Wesson
On Tue, Sep 13, 2011 at 4:18 AM, Stefan Kamphausen ska2...@googlemail.com wrote: Hi, On Tuesday, September 13, 2011 6:28:01 AM UTC+2, Ken Wesson wrote: They're trees of arrays of 32 items, and the trees can in principle have arbitrary depth. So the 2^31 limit on Java arrays doesn't impact

ClojureScript for CouchDB

2011-09-13 Thread Pepijn de Vos
While reading about ClojureScript, I saw a couple of mentions of CouchDB as a use case for ClojureScript. Would anyone care to elaborate? Is this anything more than an abstract idea? There is no CouchDB compile target AFAIK, and I can't see how any of the others would work out of the box. The

Re: ClojureScript for CouchDB

2011-09-13 Thread Herwig Hochleitner
Just a little remark: Keep in mind, that clutch https://github.com/ashafa/clutch comes with a CouchDB view server that can execute Clojure code. So compiling to JS only seems desirable to me, when you can't configure an additional view server on your CouchDB. Performance wise, it should make no

heaps in clojure

2011-09-13 Thread Sunil S Nandihalli
Hi Everybody, I have a very large, but with finite size, collection. I would like to get like first 10 elements in the sorted list . I would use a heap if I were in c++ .. is there a inbuilt implementation of this in clojure? .. Is there some other way to achieve this? some sort of lazy sort

Re: heaps in clojure

2011-09-13 Thread Jonathan Fischer Friberg
There is the inbuilt sort function, also sort-by is useful. In The joy of clojure, there were an example of a lazy sort. It can be found here: http://www.manning.com/fogus/ In the file q.clj in the source code. Jonathan On Tue, Sep 13, 2011 at 1:44 PM, Sunil S Nandihalli

Re: How to compose futures?

2011-09-13 Thread Stuart Sierra
I've been spending a lot of time on the continuations aspect: http://github.com/stuartsierra/cljque -S -- 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

Re: ClojureScript for CouchDB

2011-09-13 Thread Chas Emerick
First, what Herwig said. :-) Second, it's not outside of the realm of possibility that clutch might eventually be able to take .cljs files (or clojure/cljs source inline via clutch macro), invoke the cljs compiler, and use its existing functionality to upload the resulting view functions' code

Re: ClojureScript for CouchDB

2011-09-13 Thread Stuart Sierra
Just an idea at the moment. We need more people with knowledge of CouchDB to work on it. -Stuart Sierra clojure.com -- 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

Problem with insert-values (clojure.contrib.sql)

2011-09-13 Thread finbeu
Houston, I have a problem: (sql/with-connection db_spec (sql/insert-values MyTable [Number Name FloatValue] [5, A, 2.0] [6 ,B, 3.0]) This works perfectly fine. Now I'm trying to do the following: (def x [[5, A, 2.0] [6 ,B, 3.0]]) (sql/with-connection db_spec

Re: Problem with insert-values (clojure.contrib.sql)

2011-09-13 Thread Meikel Brandmeyer (kotarak)
Hi, comparing the two calls, I suppose you need apply. (def x [[5, A, 2.0] [6 ,B, 3.0]]) (sql/with-connection db_spec (apply sql/insert-values MyTable [Number Name FloatValue] x)) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Re: ClojureScript for CouchDB

2011-09-13 Thread Pepijn de Vos
What needs to be done? Pepijn On Sep 13, 2011, at 2:30 PM, Stuart Sierra wrote: Just an idea at the moment. We need more people with knowledge of CouchDB to work on it. -Stuart Sierra clojure.com -- You received this message because you are subscribed to the Google Groups Clojure

Re: heaps in clojure

2011-09-13 Thread Chouser
On Tue, Sep 13, 2011 at 7:44 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hi Everybody,  I have a very large, but with finite size, collection. I would like to get like first 10 elements in the sorted list . I would use a heap if I were in c++ .. is there a inbuilt implementation 

Re: Problem with insert-values (clojure.contrib.sql)

2011-09-13 Thread finbeu
oh yes. Now it works. Thanks for the quick response! BTW: Does someone know how I can keep the connection always open? If I understand it right, with-connection does a connect and login to the db each time it gets called. Isn't this quite inefficient? - Finn -- You received this message

[ANN] Clojure 1.3 RC0

2011-09-13 Thread Christopher Redinger
Clojure 1.3 RC0 is now available at http://clojure.org/downloads Changes since Beta 3: * Optimization should not demote BigInts (CLJ-836) * Added Intrinsics * fix nary-inline so *unchecked-math* works again Please download it and let us know how it works for you. 1.3 is getting close. -- You

Re: Problem with insert-values (clojure.contrib.sql)

2011-09-13 Thread Sean Corfield
On Tue, Sep 13, 2011 at 6:49 AM, finbeu info_pe...@t-online.de wrote: BTW: Does someone know how I can keep the connection always open? If I understand it right, with-connection does a connect and login to the db each time it gets called. Isn't this quite inefficient? Take a look at

Re: good ways to deal with compiler errors in SLIME (emacs)

2011-09-13 Thread Phil Hagelberg
On Tue, Sep 13, 2011 at 1:55 AM, Sergey Didenko sergey.dide...@gmail.com wrote: How can I see the error line number in SLIME? Or even somehow place editor point on the place of the error? However when I load this file in the SLIME repl it just prints: Unable to resolve symbol: dd in this

Re: [ANN] Clojure 1.3 RC0

2011-09-13 Thread Sean Corfield
On Tue, Sep 13, 2011 at 6:02 AM, Christopher Redinger redin...@gmail.com wrote: Clojure 1.3 RC0 is now available at http://clojure.org/downloads Changes since Beta 3: * Optimization should not demote BigInts (CLJ-836) * Added Intrinsics Could someone speak to this change since it didn't have

Re: Clojure vs Scala - anecdote

2011-09-13 Thread Nathan Sorenson
I adore Clojure as well, but could this success not be partially due to the reimplementing for the second time phenomenon? i.e. if you re- wrote the entire thing in Scala again, perhaps you would see similar gains in brevity etc? On Sep 6, 10:32 pm, Sean Corfield seancorfi...@gmail.com wrote: I

Re: Clojure vs Scala - anecdote

2011-09-13 Thread Laurent PETIT
Isn't it Brooks who said you will throw it away at least 3 times, or something like this ? :) 2011/9/13 Nathan Sorenson n...@sfu.ca I adore Clojure as well, but could this success not be partially due to the reimplementing for the second time phenomenon? i.e. if you re- wrote the entire thing

Programmer Day

2011-09-13 Thread Wilker
(println (apply str (map char [72 97 112 112 121 32 80 114 111 103 114 97 109 109 101 114 32 68 97 121 33]))) --- Wilker Lúcio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to

Re: Programmer Day

2011-09-13 Thread Chouser
On Tue, Sep 13, 2011 at 12:31 PM, Wilker wilkerlu...@gmail.com wrote: (println (apply str (map char [72 97 112 112 121 32 80 114 111 103 114 97 109 109 101 114 32 68 97 121 33]))) What kind of day is that, anyway? (let [m map, c comp, p partial, s str] (m (c symbol (p apply s) (p m (c char

Re: Migration to 1.3 for mortals

2011-09-13 Thread Jan Rychter
On Sep 13, 1:44 am, Stuart Sierra the.stuart.sie...@gmail.com wrote: Since the new, separated contrib libraries are supposed to be compatible with Clojure 1.2, you could perhaps also start migrating one lib at a time at your leisure.  This might even enable you to contribute to a migration

Re: Clojure vs Scala - anecdote

2011-09-13 Thread Meikel Brandmeyer
“Plan to throw one away.” -- 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 first post. To unsubscribe from this

Re: Clojure vs Scala - anecdote

2011-09-13 Thread Sean Corfield
On Tue, Sep 13, 2011 at 9:48 AM, Nathan Sorenson n...@sfu.ca wrote: I adore Clojure as well, but could this success not be partially due to the reimplementing for the second time phenomenon? i.e. if you re- wrote the entire thing in Scala again, perhaps you would see similar gains in brevity

Re: good ways to deal with compiler errors in SLIME (emacs)

2011-09-13 Thread Sergey Didenko
Thanks, Phil ! That's it. I was using slime-load-file instead of slime-compile-and-load-file If you compile using C-c C-k (where it sends the filename instead of the contents of the file) then it can determine line numbering. -- You received this message because you are subscribed to the

Re: heaps in clojure

2011-09-13 Thread Jason Wolfe
There is java.util.PriorityQueue, which is heap-based: http://download.oracle.com/javase/1,5.0/docs/api/java/util/PriorityQueue.html -Jason On Sep 13, 4:44 am, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hi Everybody,  I have a very large, but with finite size, collection. I would

Re: Clojure vs Scala - anecdote

2011-09-13 Thread Laurent PETIT
Oh, it was just one, after all ? Please, don't tell this to my boss :-D 2011/9/13 Meikel Brandmeyer m...@kotka.de “Plan to throw one away.” -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Macros in ClojureScript

2011-09-13 Thread Timothy Baldridge
While working with ClojureScript I came across a interesting question. When compiling cljs files, how does Clojure handle macros? Normally macros are run at compile-time, but in this case the compile-time platform is completely different than the run time platform. My guess is that the compiler

N00b alert! - A question on immutable/mutable data structures...

2011-09-13 Thread Trevor
For the most part, I *believe* I understand why immutable data structures with transactions are important to manage concurrent operations to shared data, but I often wonder why it matters in some cases... For example, what if I have a hash-map that needs to handle concurrent changes to the data

Re: Macros in ClojureScript

2011-09-13 Thread Laurent PETIT
Hi, 2011/9/14 Timothy Baldridge tbaldri...@gmail.com While working with ClojureScript I came across a interesting question. When compiling cljs files, how does Clojure handle macros? Normally macros are run at compile-time, but in this case the compile-time platform is completely different

Re: N00b alert! - A question on immutable/mutable data structures...

2011-09-13 Thread Andy Fingerhut
To my knowledge, there are no built-in data structures that are mutable and that use the same access functions. There are built-in data structures called transients that are mutable, and use almost the same hash functions. Read the docs on transient, persistent!, conj!, etc. Transient data

Re: N00b alert! - A question on immutable/mutable data structures...

2011-09-13 Thread Stuart Halloway
For example, what if I have a hash-map that needs to handle concurrent changes to the data structure, but never needs to have concurrent changes to a given piece of data (i.e a key/value pair). Wouldn't there be value in being able to modify the data in-place without making a copy, or needing

Re: Macros in ClojureScript

2011-09-13 Thread David Nolen
You can reference macros defined in *clojure* files that are on your classpath like this: (ns my.namespace (:require-macros [my.macros :as my]) The ClojureScript compiler will use these macros to expand your ClojureScript source. Works great. David On Tue, Sep 13, 2011 at 6:31 PM, Timothy

Re: N00b alert! - A question on immutable/mutable data structures...

2011-09-13 Thread Trevor
Thanks for the quick responses. I'll try to answer Andy's question: How do you know, in advance, that it doesn't need to handle such concurrent changes? ... and at the same time I will try to provide this example to Stuart, hoping I can see how using a map inside an atom might work: Let's say my

Calling a Java call with array from Clojure

2011-09-13 Thread ron peterson
I have a following API call that I need to make from Clojure: class A doSomething(java.lang.String arg1, String... args) so I tried (def a (new A)) ;this works (.doSomething a abc efg hij) ;this doesn't work giving me no matching method found: doSomething for class A -- You received this

Re: Calling a Java call with array from Clojure

2011-09-13 Thread Luc Prefontaine
user= (class (into-array String [s a])) [Ljava.lang.String; Luc P. On Tue, 13 Sep 2011 18:21:31 -0700 (PDT) ron peterson peterson.ron...@gmail.com wrote: I have a following API call that I need to make from Clojure: class A doSomething(java.lang.String arg1, String... args) so I

Re: Calling a Java call with array from Clojure

2011-09-13 Thread Luc Prefontaine
Oups I did read the code entirely... you defined a varg method ? On Tue, 13 Sep 2011 21:34:33 -0400 Luc Prefontaine lprefonta...@softaddicts.ca wrote: user= (class (into-array String [s a])) [Ljava.lang.String; Luc P. On Tue, 13 Sep 2011 18:21:31 -0700 (PDT) ron peterson

Re: Calling a Java call with array from Clojure

2011-09-13 Thread Luc Prefontaine
My typos errors are horrible tonight, new laptop, new keyboard. So if you defined a variable argument Java method the String array should work. But I am not certain about the intent of ... in your code excerpt. On Tue, 13 Sep 2011 21:43:03 -0400 Luc Prefontaine lprefonta...@softaddicts.ca wrote:

Rounding the edges of an Emacs beginner

2011-09-13 Thread Timothy Washington
Hey all, So I'm still an avid vim user. But I see a lot of power in the swank slime setup, and have been teaching myself emacs to try to leverage it. There are still a few tricks I haven't got. Maybe my notes are just disorganised, but I was hoping fellow Clojurians can chime in. - ?

Re: Calling a Java call with array from Clojure

2011-09-13 Thread Alan Malloy
Varargs are a fiction of javac, and do not exist at the bytecode level. In real life, this method takes two args, a String and a String[]. Use into-array to create a string array, and pass that as the second arg. On Sep 13, 6:21 pm, ron peterson peterson.ron...@gmail.com wrote: I have a

Re: Rounding the edges of an Emacs beginner

2011-09-13 Thread Phil Hagelberg
On Tue, Sep 13, 2011 at 7:13 PM, Timothy Washington twash...@gmail.com wrote: ? getting an error when I i) M-x slime-connect or ii) send a form (+1 1) to swank ; this is after i) a lein swank then ii) in another window emacs M-x connect . ** Evaluating Slime forms seems to work after that Have

Re: Rounding the edges of an Emacs beginner

2011-09-13 Thread Timothy Washington
Oh nice one mate. Yes, I tried M-x clojure-jack-in. The main feature I'm looking for is to be able to run a jetty / compojure stack, then connect / jack-in to that. But now that I think about it, I can probably just pass a run jetty / ring form to swank to start it :) Let me know if I'm on the

Re: Calling a Java call with array from Clojure

2011-09-13 Thread ron peterson
Thank you very much. Your suggestions worked: (.doSomething a abc (into-array String [efg hij])) On Sep 13, 7:33 pm, Alan Malloy a...@malloys.org wrote: Varargs are a fiction of javac, and do not exist at the bytecode level. In real life, this method takes two args, a String and a String[].

run clj file get user/counter-app error?

2011-09-13 Thread jayvandal
I am running a swing tutorial clojure program file and when I run the result is ++ user= (load-file c:/clojure-1.2.1/counter-app.clj) #'user/counter-app user= ++ What does this line mean? #'user/counter-app The name of my file

Re: Problem with insert-values (clojure.contrib.sql)

2011-09-13 Thread finbeu
Sean, thx for the hint. But how do I use the connectionpool now from clojure.java.jdbc? (defn db-update-or-insert Updates or inserts a fruit [record] (sql/with-connection db (sql/update-or-insert-values :fruit [name=? (:name record)] record))) In my scenario, I just

Re: Problem with insert-values (clojure.contrib.sql)

2011-09-13 Thread Sean Corfield
On Tue, Sep 13, 2011 at 10:43 PM, finbeu info_pe...@t-online.de wrote: But how do I use the connectionpool now from clojure.java.jdbc? Did you read that documentation? Does it not provide enough information? Let me know so I can make it better. -- Sean A Corfield -- (904) 302-SEAN An