Re: struct question

2009-01-21 Thread Mark Engelberg
Thanks for the thread links. This is basically what I suspected -- if you want to use structs in multimethods, you have to roll your own constructor which adds some kind of "type" tag to either the hashmap or the metadata. It just seems like a common case, so I was hoping there was a more conven

Re: Agent as a processing queue

2009-01-21 Thread Timothy Pratley
Hi Greg Here is a proof of concept of one approach you could take: http://groups.google.com/group/clojure/web/job-queue.clj A set of agents are maintained to represent computation jobs. When the results are gathered, the agent is thrown away. I think using multiple agents in this way could be qu

Re: struct question

2009-01-21 Thread Jason Wolfe
On Jan 21, 10:48 pm, Mark Engelberg wrote: > Is there any way to determine whether something is a "struct" (versus > an ordinary hash map), and if so, determine which kind of struct it > was built from? P.S., for the first part, you can use (instance? clojure.lang.PersistentStructMap x ) alt

Re: struct question

2009-01-21 Thread Jason Wolfe
I feel like I've seen an answer to this before, but I can't find the specific thread now. However, the following two threads seem to have very closely related info (including a reply or two from Rich). http://groups.google.com/group/clojure/browse_thread/thread/a5e0ba6480d04829/e8e2a14c77f5babf?

Re: greatest and least

2009-01-21 Thread Jason Wolfe
I support something like this. Also maybe see my "maximal-elements" here: http://groups.google.com/group/clojure/browse_thread/thread/134642cc76de17f7?hl=en# A nice feature of getting all the maximal elements is you can do (first (maximal-elements ...)) to recreate functions like yours but also

struct question

2009-01-21 Thread Mark Engelberg
Is there any way to determine whether something is a "struct" (versus an ordinary hash map), and if so, determine which kind of struct it was built from? For example, in Scheme, consider (define-struct circle (x y radius)), you get a circle? predicate for free that knows how to distinguish betwee

Re: Streams work

2009-01-21 Thread Mark H.
On Jan 21, 5:21 pm, e wrote: > I would think it would be useful to have something exactly like a stream but > that allowed as many iterators as you like but that a mutex prevented any > two from consuming the same piece of information.   That might be useful for something, but it's hard to make

very simple javascript source using clojurescript?

2009-01-21 Thread Allen Rohner
Chouser, how usable is clojurescript to generate extremely simple javascript calls? When creating HTML templates, I find myself using ugly string interpolation to generate the .js. I would really love it if I could do something like: (clojurescript/str (swfobject/embedSWF "open-flash-chart.swf" "

Agent as a processing queue

2009-01-21 Thread Greg Harman
I'd like to implement a processing queue in which I'll asynchronously drop events (represented by, say, a structmap) onto a queue, and retrieve the results later. One possible approach to this could be using an agent to store the results (the agent's controlled state is a collection of results fr

greatest and least

2009-01-21 Thread Vincent Foley
A couple months ago, there was a discussion in this group about the functions max and min and making them work with data types other than numbers. I was toying around tonight, and I wrote the following functions. (defn- boundary [compare-fn f & args] (reduce (fn [a b] (if (compare-fn (compar

Re: Is 'every?' broken?

2009-01-21 Thread Daniel Jomphe
wwmorgan wrote: > map is lazy, but to-array is not. The output you are seeing is the > result of to-array needing to realize every element of its collection. > every? only applies its predicate to as many elements of its > collection as are necessary. See the following: Thank you. This became m

Re: Streams work

2009-01-21 Thread Rich Hickey
On Jan 21, 2009, at 8:58 PM, Vincent Foley wrote: > > I made some tests, and if I am not mistaken, if an eos is not > specifically specified, Object is used, is that right? > > user=> > (let [iter (stream-iter (range 5))] > (def s (stream (fn [eos] > (let [x (next! iter eos)]

Re: Streams work

2009-01-21 Thread Vincent Foley
I made some tests, and if I am not mistaken, if an eos is not specifically specified, Object is used, is that right? user=> (let [iter (stream-iter (range 5))] (def s (stream (fn [eos] (let [x (next! iter eos)] (if (= eos x) (do (pr

Re: Mysterious performance anomalies

2009-01-21 Thread e
amazing. Some day there will be a book written about this perfect storm: "The Language Age". Ok, I admit. I started watching this presentation last night: http://www.parleys.com/display/PARLEYS/Home#talk=2556139;slide=1;title=The%20future%20will%20be%20about%20programming%20languages did I see

printing deeply nested things

2009-01-21 Thread Stuart Halloway
Consider the function deeply-nested: (defn deeply-nested [n] (loop [n n result [:bottom]] (if (= n 0) result (recur (dec n) [result] If you print it at the REPL for small values of n, no problem: (deeply-nested 25) -> [[:bottom]

Re: Streams work

2009-01-21 Thread e
> > Well, it's the combination of a seq being persistent and a stream > being one-pass - to realize the seq you'll need that pass. could be implemented still doing that pass . . . and --> This may be where you are headed in the To Be Continued, but it out to be possible to wrap a sequence with a

(clojure.contrib.lazy-seqs/combinations) should return [[]], not nil?

2009-01-21 Thread Jason Wolfe
I just got bit by (clojure.contrib.lazy-seqs/combinations) returning nil, not [[]] as I expected. I could see arguments for either being the "correct" output, but let me give my case for [[]]. In my mind, asking what the output of (combinations) should be is completely analogous to asking what t

Re: Streams work

2009-01-21 Thread Rich Hickey
On Jan 21, 8:05 pm, e wrote: > I'm stopping to write this after the seq definition (bullet) to give you my > exact feeling moving on. You may find that that is ok and that I will get > it by the end of the page: > > What I assume at this point to be true is that if I first use an iter to * > c

Re: Streams work

2009-01-21 Thread e
I would think it would be useful to have something exactly like a stream but that allowed as many iterators as you like but that a mutex prevented any two from consuming the same piece of information. So if a lot of agents had a handle to a stream, would they have to attach and detach iterators to

Re: Streams work

2009-01-21 Thread e
I'm stopping to write this after the seq definition (bullet) to give you my exact feeling moving on. You may find that that is ok and that I will get it by the end of the page: What I assume at this point to be true is that if I first use an iter to * consume* some of the stream, that part is use

Re: Streams work

2009-01-21 Thread Rich Hickey
On Jan 21, 7:40 pm, Vincent Foley wrote: > I have a question regarding the examples, specifically map* and > filter* > > (defn map* [f coll] > (let [iter (stream-iter coll)] > (stream > (fn [eos] >(let [x (next! iter eos)] > (if (= eos x) x (f x))) > > (take 4 (m

Re: Streams work

2009-01-21 Thread Jeremy Bondeson
Excellent! In case anyone else has the same problem I did: if the latest swank- clojure blows up on you, merging in the changes from the trunk will solve it. This is fairly painless as there are only a few conflicts. --~--~-~--~~~---~--~~ You received this messag

Re: Streams work

2009-01-21 Thread Vincent Foley
I have a question regarding the examples, specifically map* and filter* (defn map* [f coll] (let [iter (stream-iter coll)] (stream (fn [eos] (let [x (next! iter eos)] (if (= eos x) x (f x))) (take 4 (map* inc (filter* even? (range 100 -> (1 3 5 7) How is e

Re: pmap memory hogging

2009-01-21 Thread Mark Fredrickson
> It could be that the two threads are contending over the Array object > reference (Java arrays aren't pointers). Is there a nice way to > create "subvector" objects that only reference the underlying memory > and not the parent array object? You might be interested in the *Buffer classes (e.g.

Re: Basic about setting upp Clojure and editor enviroment

2009-01-21 Thread lpetit
Did you encounter these problems with a recent codebase, or was it days or weeks ago ? We had reports of correct installations on Windows, Imac and Linux boxes with recent codebase. One use solved a problem on mac that could be the one you are faced with ? : " The issue was that clojure.jar was

Re: pmap memory hogging

2009-01-21 Thread chris
Is the mmap interface a possibility? You could bulkget an array for each thread. I guess that would probably not gain much against just copying an array for each thread. I couldn't find a way to create a subvector of a java array. Chris On Jan 21, 12:20 pm, "Mark H." wrote: > On Jan 21, 8:56

Re: Mysterious performance anomalies

2009-01-21 Thread Rich Hickey
On Jan 21, 5:02 pm, Jon Harrop wrote: > On Tuesday 20 January 2009 21:41:29 Rich Hickey wrote: > > > This issue (TCO) is resolved - it's a limitation of the JVM that > > Clojure accepts. If that is a significant problem for anyone they > > should either not use Clojure or work on adding TCO to

Re: Mysterious performance anomalies

2009-01-21 Thread Jon Harrop
On Tuesday 20 January 2009 21:41:29 Rich Hickey wrote: > This issue (TCO) is resolved - it's a limitation of the JVM that > Clojure accepts. If that is a significant problem for anyone they > should either not use Clojure or work on adding TCO to the JVM via the > MLVM effort: > > http://openjdk.j

Re: Streams work

2009-01-21 Thread Frantisek Sodomka
Hello Rich, Looking forward to using them! It is pleasure to see such nice development! Frantisek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googleg

Re: Clojure Web Libraries

2009-01-21 Thread Stephen C. Gilardi
On Jan 21, 2009, at 4:39 PM, Frank wrote: I am interested in trying to use Clojure to develop web-based applications. Can someone point me to any Clojure libraries that have been written that I can use. Thanks. Compojure and webjure are two names worthy of Google searches along those line

Clojure Web Libraries

2009-01-21 Thread Frank
Hi, I am interested in trying to use Clojure to develop web-based applications. Can someone point me to any Clojure libraries that have been written that I can use. Thanks. Frank --~--~-~--~~~---~--~~ You received this message because you are subscribed to the G

Re: Basic about setting upp Clojure and editor enviroment

2009-01-21 Thread Tom Ayerst
Sadly, it would not install for me. I am running 3.4.1 and I do Java dev so I should have all the dependencies. It installs without complaint but comes up broken in the about plugins and there is no function ality to be found. Tom 2009/1/21 lpetit > > Hello, > > If you want to give a "try" to

Re: Gorilla issue with recent builds?

2009-01-21 Thread Mark Volkmann
On Wed, Jan 21, 2009 at 3:06 PM, Meikel Brandmeyer wrote: > Hi, > > Am 21.01.2009 um 21:44 schrieb Mark Volkmann: > >> What is the difference between vimclojure and Gorilla? > > VimClojure provides static things like syntax highlighting, > indenting and static code completion as supported by > Vi

Re: Streams work

2009-01-21 Thread Timothy Pratley
> Feedback welcome Brilliant! :) --~--~-~--~~~---~--~~ 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 clojure

Re: Gorilla issue with recent builds?

2009-01-21 Thread Meikel Brandmeyer
Hi, Am 21.01.2009 um 21:44 schrieb Mark Volkmann: What is the difference between vimclojure and Gorilla? VimClojure provides static things like syntax highlighting, indenting and static code completion as supported by Vim (). It's purely Vim and needs nothing else. Gorilla supplements VimClo

Re: Gorilla issue with recent builds?

2009-01-21 Thread Mark Volkmann
What is the difference between vimclojure and Gorilla? On Wed, Jan 21, 2009 at 2:01 PM, Meikel Brandmeyer wrote: > Hi, > > Am 21.01.2009 um 17:25 schrieb Mark Feeney: > >> Anyone else having issues with Gorilla with "recent" SVN builds of >> clojure and clojure-contrib? What I'm seeing is that

Re: Gorilla issue with recent builds?

2009-01-21 Thread Meikel Brandmeyer
Hi, Am 21.01.2009 um 17:25 schrieb Mark Feeney: Anyone else having issues with Gorilla with "recent" SVN builds of clojure and clojure-contrib? What I'm seeing is that the main commands (es, et, eb, ef, etc.) work as usual, but the in-Vim Repl, doesn't seem to display any evaluation output. N

Re: running Gorilla

2009-01-21 Thread Meikel Brandmeyer
Hi, Am 21.01.2009 um 14:06 schrieb bOR_: Just for posterity: It took me a while to realize that my fresh vim didn't have a maplocalleader defined. Had to add it to the .vimrc so that chimp (and I guess gorilla as well) would actually have some keybindings associated with it. let maplocalleader

Streams work

2009-01-21 Thread Rich Hickey
I've started documenting the streams work I have been doing, for those interested: http://clojure.org/streams Feedback welcome, Rich --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: Another socket repl

2009-01-21 Thread Craig McDaniel
> I wonder if it wouldn't be a good idea to move the call to binding > fromsocket-replinto accept-fn. It seems like a reasonable default to rebind > *in* and *out* for the duration of the accepting function; the example > uses this as does my application. I'm not sure that rebinding *in* and *ou

Re: pmap memory hogging

2009-01-21 Thread Mark H.
On Jan 21, 8:56 am, Perry Trolard wrote: > If I understand what you did correctly, the reason it worked for you > is that Rich committed a fix to SVN in the meantime! Awesome, real-time fix! > > The last (count result-p) call takes a few seconds (probably > > because there's a one-to-one mappin

Re: Is 'every?' broken?

2009-01-21 Thread wwmorgan
map is lazy, but to-array is not. The output you are seeing is the result of to-array needing to realize every element of its collection. every? only applies its predicate to as many elements of its collection as are necessary. See the following: user=> (every? print-arg [true false true]) [true]

Request for code examples: definline and 'full' macro syntax

2009-01-21 Thread Anand Patil
Hi all, Does anyone have, or know where I can find, simple working examples showing the use of: - definline - defmacro with all the fields, (defmacro name doc-string? attr-map? ([params*] body) + attr-map?) I get doc-string, but don't understand: - attr-map - (...) + attr-map - the preci

Is 'every?' broken?

2009-01-21 Thread Daniel Jomphe
(defn print-arg [x] (let [result# x] (println (format " [%s] " result#)) result#)) (every? true? (map #(print-arg %) [true false true])) ; [true] ; [false] ;false (ev

Re: Basic about setting upp Clojure and editor enviroment

2009-01-21 Thread lpetit
Hello, If you want to give a "try" to clojure-dev (but you may well end up using it if you can afford all its current limitations :-), I'll recommand these two links : - documentation page : the first lines explain how to install it (as easy as installing any eclipse plugin from an eclipse updat

Re: Basic about setting upp Clojure and editor enviroment

2009-01-21 Thread Matt Revelle
On Jan 21, 2009, at 11:33 AM, Tom Ayerst wrote: > If you are an emacs fan I am told Clojurebox, no contest. If you already use Emacs but aren't sure how to get Clojure support setup, Bill Clementson has plenty of helpful posts: http://bc.tech.coop/blog/081023.html http://bc.tech.coop/blog/0812

Re: pmap memory hogging

2009-01-21 Thread Perry Trolard
Thanks for testing, Mark. If I understand what you did correctly, the reason it worked for you is that Rich committed a fix to SVN in the meantime! > The last (count result-p) call takes a few seconds (probably > because there's a one-to-one mapping of tasks to sequence > elements) but it finish

Re: Basic about setting upp Clojure and editor enviroment

2009-01-21 Thread Tom Ayerst
If you are an emacs fan I am told Clojurebox, no contest. If you are not comfortable with emacs I would recommend using a basic editor (if you want syntax highlighting you could use JEdit with the clojure config (search for it in the e-mail archive)) and a repl running from the commeand line (for

Gorilla issue with recent builds?

2009-01-21 Thread Mark Feeney
Hi all, Anyone else having issues with Gorilla with "recent" SVN builds of clojure and clojure-contrib? What I'm seeing is that the main commands (es, et, eb, ef, etc.) work as usual, but the in-Vim Repl, doesn't seem to display any evaluation output. No errors on stdout of the gorilla server.

Re: repl-utils show

2009-01-21 Thread Chouser
On Wed, Jan 21, 2009 at 10:29 AM, Mark Volkmann wrote: > > What does "321" represent? user=> (show 321 :bridge) === public final java.lang.Integer === [32] compareTo : int (Object) nil 321 is an Integer literal. When 'show' sees a non-class as its first argument, it fetchs the object's class

Re: Basic about setting upp Clojure and editor enviroment

2009-01-21 Thread Matt Clark
If you're not already an emacs user, I found it can be quite the learning curve getting into it. So I'd recommend you also give the eclipse clojure-dev plugin a shot. It now has a REPL, namespace browser, syntax highlighting, etc and works fine on windows. http://code.google.com/p/clojure-dev/ O

Re: repl-utils show

2009-01-21 Thread Mark Volkmann
On Wed, Jan 21, 2009 at 9:18 AM, Chouser wrote: > > On Wed, Jan 21, 2009 at 9:52 AM, Mark Volkmann > wrote: >> >> On Wed, Jan 21, 2009 at 7:44 AM, Chouser wrote: >>> >>> On Wed, Jan 21, 2009 at 12:05 AM, Chouser wrote: The predicate takes a map based on the 'bean' of the member objec

Re: repl-utils show

2009-01-21 Thread Chouser
On Wed, Jan 21, 2009 at 9:52 AM, Mark Volkmann wrote: > > On Wed, Jan 21, 2009 at 7:44 AM, Chouser wrote: >> >> On Wed, Jan 21, 2009 at 12:05 AM, Chouser wrote: >>> >>> The predicate takes a map based on the 'bean' of the member object, >>> but with :text and :member keys added. The :text is w

Re: Basic about setting upp Clojure and editor enviroment

2009-01-21 Thread bOR_
If you are running windows, clojurebox is the easiest way to set things up. On linux, this guide might help: http://riddell.us/clojure/ On Jan 21, 3:05 pm, anderspe wrote: > Hello, i am waiting for the book "Programming Clojure" by Stuart > Halloway, > I have set upp a enviroment that i can run

Re: repl-utils show

2009-01-21 Thread Mark Volkmann
On Wed, Jan 21, 2009 at 7:44 AM, Chouser wrote: > > On Wed, Jan 21, 2009 at 12:05 AM, Chouser wrote: >> >> The predicate takes a map based on the 'bean' of the member object, >> but with :text and :member keys added. The :text is what will be >> printed, the :member is the original member objec

Basic about setting upp Clojure and editor enviroment

2009-01-21 Thread anderspe
Hello, i am waiting for the book "Programming Clojure" by Stuart Halloway, I have set upp a enviroment that i can run a REPL and load script. But i am looking for som basic info about sett upp interaction to a editor, EMACS or... I have tryed Plugin to Netbeans but it was Alpha and have som prob

Re: Proposal: "smarter" set operations that take size into account for speed

2009-01-21 Thread pc
I think that having efficient algorithms for the fundamental data structures is extremely important. But Rich and the Contributers must have tons of other stuff to worry about. In the meantime I will use Jason's fix. On Jan 20, 8:27 pm, Mark Engelberg wrote: > I say "thumbs up" to this proposal.

Re: repl-utils show

2009-01-21 Thread Chouser
On Wed, Jan 21, 2009 at 12:05 AM, Chouser wrote: > > The predicate takes a map based on the 'bean' of the member object, > but with :text and :member keys added. The :text is what will be > printed, the :member is the original member object itself. This means that (as of clojure svn 1221) you c

Re: bug: bean returns the wrong kind of false

2009-01-21 Thread Rich Hickey
On Jan 21, 12:14 am, Chouser wrote: > The first method of the String class does not take varargs: > user=> (.isVarArgs (first (.getMethods String))) > false > > The above is the Right Kind of False, as shown here: > user=> (if (.isVarArgs (first (.getMethods String))) :true :false) > :false > >

Re: running Gorilla

2009-01-21 Thread bOR_
Just for posterity: It took me a while to realize that my fresh vim didn't have a maplocalleader defined. Had to add it to the .vimrc so that chimp (and I guess gorilla as well) would actually have some keybindings associated with it. let maplocalleader = "," Gracias! On Dec 19 2008, 8:26 am, M

Re: clojure.contrib.sql - Support DataSource in with-connection

2009-01-21 Thread Juergen Gmeiner
On Jan 21, 4:12 am, "Stephen C. Gilardi" wrote: > On Jan 20, 2009, at 7:01 PM, Stephen C. Gilardi wrote: > > I've checked in an implementation for this. I confirmed that it > doesn't harm the jdbc url method of connecting, but I don't have a > DataSource setup to test the DataSource method. Juerg