Re: positions

2009-11-20 Thread nchubrich
My 'requirements' were not so much for any particular need, but to try to think up a logical and complete API for dealing with multisets. I agree that there should be an actual collection type for multisets (implemented as an underlying map of values to frequencies I presume); but you might as

Re: A macro for flexible keyword argument handling

2009-11-20 Thread nchubrich
I don't see why you couldn't simply check to make sure that there are no arguments without either default or supplied values. As I wrote above, If you left the arguments incomplete and unkeyworded it would apply what you put preferentially to the first arguments in the list without a default

repeatedly forcing the evaluation of a lazy seq

2009-11-20 Thread bOR_
Hi all, Just ran into a small gotcha: I had an atom which contained a lazyseq (e.g. (filter males world)). Later on I would be repeatedly calling random elements from this atom, using clojure contrib rand-elt. That was surprisingly slow. I figured out that count was the culprit. Apparently, the

Re: A macro for flexible keyword argument handling

2009-11-20 Thread nchubrich
I should also add something I alluded to in another discussion (under 'positions'); this is the idea of making \any parameter into a rest parameter. For instance, if you had (defnsk add [addend augend] ...) you could call it like (add :addend 1 2 3 :augend 1 2) or (add [1 2 3] [1 2 3 4]). Must

Suggestion: Add should_cache? flag to lazy-seq

2009-11-20 Thread Gabi
This would solve the holding to the head problem. Many times, lazy-seq would be used without the need to get the same cell twice. In this case, avoiding cashing would both enhance performance and more importantly would avoid OutOfMemoryError Exceptions like in: (def r (repeatedly #(rand))) (last

Re: positions

2009-11-20 Thread nchubrich
If you think about it, the tower of sequence types is like this: seq | gathered seq /\ multiset permutation \ / set The way to do the various options I pointed out is to mix types: the

Re: Suggestion: Add should_cache? flag to lazy-seq

2009-11-20 Thread Jarkko Oranen
On Nov 19, 11:52 am, Gabi bugspy...@gmail.com wrote: This would solve the holding to the head problem. Many times, lazy-seq would be used without the need to get the same cell twice. In this case, avoiding cashing would both enhance performance and more importantly would avoid

Re: A macro for flexible keyword argument handling

2009-11-20 Thread Constantine Vetoshev
On Nov 20, 8:33 am, nchubrich nicholas.chubr...@gmail.com wrote: I guess this is getting to be a pretty epic macro!  I figured it was worth inviting boos and/or cheers and suggestions before setting out... Far be it from me to discourage making function invocation semantics more flexible! Just

Re: [ANN] leiningen - a Clojure build tool

2009-11-20 Thread Graham Fawcett
On Wed, Nov 18, 2009 at 2:29 AM, Phil Hagelberg p...@hagelb.org wrote: With Leiningen, your build is described using Clojure. You can put any code you like in your project.clj file; the only requirement is that it includes a call to defproject. You can define your own tasks in there if you

Re: leiningen - a Clojure build tool

2009-11-20 Thread Sean Devlin
The Incanter guys put something up: http://incanter-blog.org/2009/11/20/leiningen-clojars/ On Nov 20, 11:06 am, Graham Fawcett graham.fawc...@gmail.com wrote: On Wed, Nov 18, 2009 at 2:29 AM, Phil Hagelberg p...@hagelb.org wrote: With Leiningen, your build is described using Clojure. You can

Re: leiningen - a Clojure build tool

2009-11-20 Thread Graham Fawcett
On Fri, Nov 20, 2009 at 11:11 AM, Sean Devlin francoisdev...@gmail.com wrote: The Incanter guys put something up: http://incanter-blog.org/2009/11/20/leiningen-clojars/ Excellent, thanks! Leiningen + Clojars is a game-changer for Clojure. I'm very excited.

Re: leiningen - a Clojure build tool

2009-11-20 Thread Sean Devlin
Something tells me we'll just be calling it 'lein'. Is that okay Phil? Sean On Nov 20, 11:21 am, Graham Fawcett graham.fawc...@gmail.com wrote: On Fri, Nov 20, 2009 at 11:11 AM, Sean Devlin francoisdev...@gmail.com wrote: The Incanter guys put something up:

Re: leiningen - a Clojure build tool

2009-11-20 Thread Laurent PETIT
FYI: http://www.infoq.com/news/2009/11/clojars-leiningen-clojure 2009/11/20 Sean Devlin francoisdev...@gmail.com: Something tells me we'll just be calling it 'lein'.  Is that okay Phil? Sean On Nov 20, 11:21 am, Graham Fawcett graham.fawc...@gmail.com wrote: On Fri, Nov 20, 2009 at 11:11

clojure-jsr223

2009-11-20 Thread Armando Blancas
Without knowing of Niels Mayer's work (until just now) I wrote an implementation of the Java Scripting API for Clojure --and even named it the same. Indeed great minds think alike. Though I didn't think of isolating the runtime in different instances of the engine. The distribution ZIP file has

Re: take repeatedly alternative?

2009-11-20 Thread Raoul Duke
as an aside, sometimes you want the rng to be truly pure so you can easily recreate situations. take a look at randomness in haskell for fun. :-) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

tree-shaking a jarred Clojure app?

2009-11-20 Thread Graham Fawcett
Hi folks, This is somewhat a Java question, but it's in the context of Clojure, so here goes. Playing with Leiningen got me thinking about bundling a Clojure application as a JAR, which might include a host of classes that are loaded but never used. Is it possible to tree-shake such a jarfile,

Re: tree-shaking a jarred Clojure app?

2009-11-20 Thread Jim Downing
Hi Graham 2009/11/20 Graham Fawcett graham.fawc...@gmail.com: Hi folks, This is somewhat a Java question, but it's in the context of Clojure, so here goes. Playing with Leiningen got me thinking about bundling a Clojure application as a JAR, which might include a host of classes that are

Re: leiningen - a Clojure build tool

2009-11-20 Thread Phil Hagelberg
Sean Devlin francoisdev...@gmail.com writes: Something tells me we'll just be calling it 'lein'. Is that okay Phil? Yeah, there's a reason the bin script is called lein... I was misspelling it myself for the first few days of working on it. =) -Phil -- You received this message because you

Re: [ANN] Clojars - a Clojure community jar repository

2009-11-20 Thread Phil Hagelberg
Alex Osborne a...@meshy.org writes: I looks like Maven does this, it puts two files in the jar: META-INF/maven/$groupId/$artifactId/pom.xml META-INF/maven/$groupId/$artifactId/pom.properties So it looks like you can use that to figure out what version a library is just using the java

Re: tree-shaking a jarred Clojure app?

2009-11-20 Thread Graham Fawcett
On Fri, Nov 20, 2009 at 1:37 PM, Jim Downing jim.down...@gmail.com wrote: Hi Graham 2009/11/20 Graham Fawcett graham.fawc...@gmail.com: Hi folks, This is somewhat a Java question, but it's in the context of Clojure, so here goes. Playing with Leiningen got me thinking about bundling a

Re: tree-shaking a jarred Clojure app?

2009-11-20 Thread Richard Newman
But I should be able to know, through class inspection, whether my 'main' program depends on a class which uses, say, the clojure.zip namespace, and decide whether or not to include it. Or so I am wondering. There are impediments to that, too -- your namespace might require another, and so

Re: Datatypes and Protocols - early experience program

2009-11-20 Thread Chouser
On Thu, Nov 19, 2009 at 12:39 PM, Krukow karl.kru...@gmail.com wrote: On Nov 19, 12:01 am, samppi rbysam...@gmail.com wrote: Question: are the general mechanisms for accessing and setting fields their keywords and assoc respectively:   (deftype Bar [a b c d e])   (def b (Bar 1 2 3 4 5))  

Re: Datatypes and Protocols - early experience program

2009-11-20 Thread Krukow
On Nov 20, 8:51 pm, Chouser chou...@gmail.com wrote: On Thu, Nov 19, 2009 at 12:39 PM, Krukow karl.kru...@gmail.com wrote: [snip] I guess I am just asking if the performance guarantees are those I would expect of Clojure (i.e., too fast ;-)) This is definitely still too fast.  In fact, it

Re: Oh, yeah, transients are fast!

2009-11-20 Thread Raoul Duke
Try with a 1.6 JVM... wow. it actually got worse than when i was using 1.5. ... so much for hallowed write-once-run-the-same-anywhere-ish of the jvm, d'oh. Clojure 1.1.0-alpha-SNAPSHOT user= (load-file /tmp/test.clj) #'user/vrange2 user= (. System getProperty java.version) 1.6.0_15 user= (time

Re: Oh, yeah, transients are fast!

2009-11-20 Thread Raoul Duke
user= (time (def v (vrange 100))) --- never came back, i had to ^C^C (in emacs buffer)!! p.s. so at least the transient version never did that ;-) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: repeatedly forcing the evaluation of a lazy seq

2009-11-20 Thread ataggart
The sequence returned from the filter would need to be rescanned to get the nth element, but the filtering itself should only need to happen when the next element in the sequence is sought. For cases such as the one you describe, I think it's common to fully realize the sequence into a vector,

ANN: Clojuratica v2 -- Seamless Mathematica-within-Clojure!

2009-11-20 Thread Garth Sheldon-Coulson
Dear Clojurians, I am very happy to announce Clojuratica version 2. Clojuratica now offers the **syntactic** integration of Clojure and Mathematica. What does this mean? It means you can write Clojure code that looks like this: = (FactorInteger 12345) [[3 1] [5 1] [823 1]] You guessed it.

Re: ANN: Clojuratica v2 -- Seamless Mathematica-within-Clojure!

2009-11-20 Thread Garth Sheldon-Coulson
P.S. I have been told that Clojuratica works with the free Mathematica Player. I haven't tried this myself. On Fri, Nov 20, 2009 at 5:57 PM, Garth Sheldon-Coulson g...@mit.edu wrote: Dear Clojurians, I am very happy to announce Clojuratica version 2. Clojuratica now offers the **syntactic**

Weird Java Interop Behaviour

2009-11-20 Thread Matt Brown
Hi. I can't find the answer to this anywhere. (It seems it should be posted somewhere already ...) This works: (. System getProperty java.version) - 1.6.0_15 This does not work: (. (identity System) getProperty java.version) - java.lang.IllegalArgumentException: No matching method found:

Re: Weird Java Interop Behaviour

2009-11-20 Thread Mike Hinchey
It's the . special form that makes the difference. In (. System (getProperty)), the dot interprets System as a class and looks for a static method (at read/compile time). With (identity System), System resolves to a value, a Class object, returned by identity, then your outside dot looks for a

Re: Weird Java Interop Behaviour

2009-11-20 Thread Alex Osborne
Matt Brown wrote: Why does (. System getProperty java.version) work when (. (identity System) getProperty java.version) does not work, given that (identity System) should be the same as System ? It's because the . special form treats class names specially. In Java there's unfortunately a

Re: tree-shaking a jarred Clojure app?

2009-11-20 Thread John Harrop
On Fri, Nov 20, 2009 at 2:28 PM, Richard Newman holyg...@gmail.com wrote: But I should be able to know, through class inspection, whether my 'main' program depends on a class which uses, say, the clojure.zip namespace, and decide whether or not to include it. Or so I am wondering. There

Re: Oh, yeah, transients are fast!

2009-11-20 Thread John Harrop
On Fri, Nov 20, 2009 at 5:16 PM, Raoul Duke rao...@gmail.com wrote: Try with a 1.6 JVM... wow. it actually got worse than when i was using 1.5. ... so much for hallowed write-once-run-the-same-anywhere-ish of the jvm, d'oh. Clojure 1.1.0-alpha-SNAPSHOT user= (load-file /tmp/test.clj)

Clojure Scoping Rules

2009-11-20 Thread kunjaan
Even though I have used Clojure, I hadn't looked at the scoping rules in detail. I am getting more confused as I read the documentations. I made a small test to try out the scoping resolutions and am apalled at the complexity. Could somebody explain the intent and various rules that Clojure uses?

Re: Clojure Scoping Rules

2009-11-20 Thread Mark Engelberg
Conceptually, the best way to think about it is that your binding sets the global x to 100 and restores the global x to 1 when exiting the scope of the binding construct. It has no effect on your local x. Dynamic binding is confusing, and should be used with care. If you stick with the lexical

Re: Clojure Scoping Rules

2009-11-20 Thread Mark Engelberg
On Fri, Nov 20, 2009 at 8:02 PM, Mark Engelberg mark.engelb...@gmail.com wrote: Dynamic binding is confusing, and should be used with care. Elaborating on my previous point: it's especially confusing because dynamic binding interacts poorly with lazy data structures, which is predominantly what

Monad problems: finding an m-zero

2009-11-20 Thread samppi
I'm writing a maybe/state monad using clojure.contrib.monads. I've gotten by fine with using just (state-t maybe-m), but now I need different behavior: I need a monad that behaves precisely like (state-t maybe-m), except that when a monadic value mv is called on a state s and fails, (mv s)