Re: clojure-mode survey

2009-09-07 Thread Konrad Hinsen
On 8 Sep 2009, at 02:36, Phil Hagelberg wrote: > However, now that clojure-mode has the M-x clojure-install command > that > sets up SLIME etc, I don't know if the built-in subprocess features > are > worth keeping around any more. Personally I have never used them or > heard of anyone using

Re: Clojure quickstart maven archetype

2009-09-07 Thread Scott Fleckenstein
Thanks Stuart, Just an FYI, I added repl support to the clojure-maven-plugin here: http://github.com/nullstyle/clojure-maven-plugin/tree/master Rather than taking clojureshell's approach, I start a separate process similar to how the rest of the plugin works. In fact, I just needed to refactory

Re: minor grievance with arithmetic on characters

2009-09-07 Thread Timothy Pratley
According to the docstring compare returns -1, 0 or 1: user=> (compare \b \g) -5 Regards, Tim. On Sep 8, 2:02 pm, Adrian Cuthbertson wrote: > Clojure's compare; > > (compare \a \b) > -1 > > user=> (doc compare) > - > clojure.core/compare > ([x y]) >   Comparator. Retur

Re: best way to make use of association lists

2009-09-07 Thread Richard Newman
> Why not just use http://clojure.org/api#sorted-map ? Because an association list keeps insertion order, whilst a sorted-map keeps sorted order. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: best way to make use of association lists

2009-09-07 Thread kyle smith
Why not just use http://clojure.org/api#sorted-map ? --~--~-~--~~~---~--~~ 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 m

Re: minor grievance with arithmetic on characters

2009-09-07 Thread Timothy Pratley
ah nice - perfect thanks On Sep 8, 2:02 pm, Adrian Cuthbertson wrote: > Clojure's compare; > > (compare \a \b) > -1 > > user=> (doc compare) > - > clojure.core/compare > ([x y]) >   Comparator. Returns 0 if x equals y, -1 if x is logically 'less >   than' y, else 1. Same

Re: Tight loop performance

2009-09-07 Thread Richard Newman
> An interesting founding is that it seems typecasting from short to int > and asetting to an int-array is 3-4 times faster than typecasting from > int to short and asetting to an short array. Thought: Java primitive types, when manipulated individually, are all "secretly ints" — there is no re

Re: best way to make use of association lists

2009-09-07 Thread rivercheng
Hi, How about just keep a list of keys as an extra list besides the hash- map? The look-up and iterating without order can be done efficiently without the help of the key list. Iterating with the original order is a little bit expensive but should be acceptable if the hash function is fast. Cert

Re: best way to make use of association lists

2009-09-07 Thread Chouser
On Sep 7, 2009, at 5:19 PM, Conrad wrote: > > Hi everyone! I have some data that consists of key/value pairs, but > that need to maintain their order, in terms of when they were added to > the list. In most lisps you'd do this with an association list, with a > performance penalty of course if t

Re: Ann Arbor Clojure Meetup?

2009-09-07 Thread Lance Carlson
Hi Clint, I attend the Ruby meetings locally and we're all interested in functional languages.. we used to do an erlang/functional languages group. I'd also be interested in getting something like this together. -Lance On Mon, Sep 7, 2009 at 9:32 PM, newsomc wrote: > > Is anyone aware of a Cloj

Re: Tight loop performance

2009-09-07 Thread rivercheng
An interesting founding is that it seems typecasting from short to int and asetting to an int-array is 3-4 times faster than typecasting from int to short and asetting to an short array. On Sep 8, 9:33 am, evandi wrote: > I think the problem is the typecasting and the bit-shifting. I think > bot

Re: best way to make use of association lists

2009-09-07 Thread John Harrop
On Mon, Sep 7, 2009 at 5:19 PM, Conrad wrote: > Alternatively, I suppose it would be possible to create a new type of > map that performs better than an alist but can return items in the > order they were added to the list, if desired Or use an existing type: the java.util.LinkedHashMap. The do

Re: Tight loop performance

2009-09-07 Thread rivercheng
Hi, evandi: I've tried to use aset to write to a short array, and there's no typecasting and bit-shifting, but it is still slow. But if I write to a int array, it will be more than two times faster. Therefore, maybe 'aset' is optimized only for 'int' ? On Sep 8, 9:33 am, evandi wrote: > I thi

Ann Arbor Clojure Meetup?

2009-09-07 Thread newsomc
Is anyone aware of a Clojure meetup in Ann Arbor, MI? I used to attend a very small one in Brooklyn and Im missing it. If anyone is interested in starting something that could be cool too! Cheers, Clint --~--~-~--~~~---~--~~ You received this message because you

Re: Clojure quickstart maven archetype

2009-09-07 Thread Stuart Sierra
Also look at the ClojureShell Maven plugin, http://github.com/fred-o/clojureshell-maven-plugin/tree/master which runs a REPL or Swank server. -SS On Sep 7, 10:41 pm, Mark Derricutt wrote: > Most definitely - I did have a repl goal for awhile but had issues with the > input/output streams.  Loo

Re: minor grievance with arithmetic on characters

2009-09-07 Thread Adrian Cuthbertson
Clojure's compare; (compare \a \b) -1 user=> (doc compare) - clojure.core/compare ([x y]) Comparator. Returns 0 if x equals y, -1 if x is logically 'less than' y, else 1. Same as Java x.compareTo(y) except it also works for nil, and compares numbers and collections

minor grievance with arithmetic on characters

2009-09-07 Thread Timothy Pratley
Is there a way to deal with this: user=> (> \a \b) java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number (NO_SOURCE_FILE:0) So far the only things I know are to coerce or use interop eg: user=> (.compareTo \a \b) -1 --~--~-~--~~~---~--~-

Re: Looping idiom

2009-09-07 Thread Timothy Pratley
Yet another way :) user=> (map + (rest a) a) (3 5 7 9 11) --~--~-~--~~~---~--~~ 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 member

Re: clojure-mode survey

2009-09-07 Thread Phil Hagelberg
Phil Hagelberg writes: > I'm working on cleaning up the code for clojure-mode.el, which provides > Clojure support for Emacs. Further things I am considering removing: * support for Emacs 21 (which was released around 2001) * the ability to turn off highlighting multi-line def forms * the cloj

Re: Clojure quickstart maven archetype

2009-09-07 Thread Mark Derricutt
Most definitely - I did have a repl goal for awhile but had issues with the input/output streams. Looking at my github forkqueue I see someones pulled it back out (or added a new one, I've not yet had a look at it) which might be a starting point for you... But by all means - patches galore are we

ns :require vs import

2009-09-07 Thread Sean Devlin
Okay, syntax question. When defining a namespace (ns my-ns (:require [clojure.contrib [str-utils2 :as s]]) (:import (java.util Regex Date Etc))) Why does the require use a vector, and the import statement use a list? Could they both be vectors? This confused me when using imports for a whi

Re: Looping idiom

2009-09-07 Thread Sean Devlin
I'd use map, reduce, partial, and partition like so user=>(map (partial reduce +) (partition 2 1 [1 2 3 4 5 6])) (3 5 7 9 11) On Sep 7, 9:53 pm, Brian Will wrote: > should read: > > (loop [s origSeq n [ ]) >         (let [a (first s >                b (second s)] >             (if (nil? b) >  

Re: dynamic :use

2009-09-07 Thread James Sofra
I know that this has come up before on the group and but is this not essentially dependency injection where the dependency being injected is a name space that presumably follows a particular convention in terms of what functions it provides? I remember people making it pretty clear that they didn

Re: Clojure quickstart maven archetype

2009-09-07 Thread Scott Fleckenstein
One of the things that I'm not happy with my archetype with right now (I'm working on it at the moment) is that there isn't an way to support both AOT compilation as well as directly running the script that feels right. Everything I've thought about seems overwrought. Adding support for specifyin

Re: Looping idiom

2009-09-07 Thread Brian Will
should read: (loop [s origSeq n [ ]) (let [a (first s b (second s)] (if (nil? b) n (recur (rest s) (conj n (+ a b)) On Sep 7, 6:51 pm, Brian Will wrote: > Very basic question. What's the idiom for producing a new seq wherein

Looping idiom

2009-09-07 Thread Brian Will
Very basic question. What's the idiom for producing a new seq wherein each val is based on pairs from an existing seq, e.g.: ; add together n0 n1, n1 n2, n2 n3, etc. [1 2 3 4 5 6] ; giving... [3 5 7 9 11] The verbose way would be something like: (loop [s origSeq n [ ]) (let [a (first or

Re: Problem with clojure-maven-plugin and ns metadata

2009-09-07 Thread Stuart Sierra
On Mon, Sep 7, 2009 at 8:54 PM, Mark Derricutt wrote: > Initially I didn't like that as people -may- not stick to good convention > and use a different namespace than filename, but I think failing and making > them conform to a good standard is acceptable. I think if the namespace name doesn't ma

Re: Tight loop performance

2009-09-07 Thread evandi
I think the problem is the typecasting and the bit-shifting. I think both involve casting one of the parameters to a java.lang.Number. On Sep 7, 5:03 am, rivercheng wrote: > Hi, icemaze: > > With trying the following code, I found now Clojure is only around 15 > times slower than Java. (java6 -s

Re: Tight loop performance

2009-09-07 Thread evandi
I think the problem is the typecasting and the bit-shifting. I think both involve casting one of the parameters to a java.lang.Number. On Sep 7, 5:03 am, rivercheng wrote: > Hi, icemaze: > > With trying the following code, I found now Clojure is only around 15 > times slower than Java. (java6 -s

Re: [ANN] Clojure quickstart maven archetype

2009-09-07 Thread Mark Derricutt
Excellent! This was one of the missing pieces I was hoping to pull together next. > into your code, and no support fr clojure-maven-plugin clojure:run (it I could change this to check if you mention a .clj or just a class name, and run either-or. Theres also the http://mojo.codehaus.org/exec-mav

Re: clojure-mode survey

2009-09-07 Thread Stuart Sierra
On Sep 7, 8:36 pm, Phil Hagelberg wrote: > ... I don't know if the built-in subprocess features are > worth keeping around any more. Personally I have never used them or > heard of anyone using them; I wonder if they are just legacy baggage. Never used them; only use SLIME. Never used clojure-i

Is not public error?

2009-09-07 Thread Gorsal
(script.env/def-ns script.ParenMatcher (:gen-class :implements [org.eclipse.jface.text.source.ICharacterPairMatcher] :state state :init init :methods [[setPainter [org.eclipse.jface.text.source.MatchingCharacterPainter] void]]) (:use script.genutils) (:import (org.eclipse

Re: Problem with clojure-maven-plugin and ns metadata

2009-09-07 Thread Stuart Sierra
It might be sufficient to scan for files containing "(ns" and then determine the namespace name from the file name ("." becomes "/" and "-" becomes "_"). Otherwise, you might need to depend directly on Clojure and use its reader. I don't think it will work for the plugin, but I wrote a lib in Cl

Re: Problem with clojure-maven-plugin and ns metadata

2009-09-07 Thread Mark Derricutt
I had considered just searching .clj files and using the file name (filtering on (ns sounds good thou). Initially I didn't like that as people -may- not stick to good convention and use a different namespace than filename, but I think failing and making them conform to a good standard is acceptable

clojure-mode survey

2009-09-07 Thread Phil Hagelberg
I'm working on cleaning up the code for clojure-mode.el, which provides Clojure support for Emacs. It includes some functionality for interacting with subprocesses. This is a small subset of the functionality of the functionality included in SLIME, but it's simpler and easier to configure. Howe

Re: Problem with clojure-maven-plugin and ns metadata

2009-09-07 Thread Mark Derricutt
Doh - I suspected I'd have something that might trip me up on that namespace discovery :( Metadata is something I've not used too much yet.. I'll take a look at it tonight... -- Pull me down under... On Tue, Sep 8, 2009 at 11:10 AM, Stuart Sierra wrote: > Hi Mark, > > I like your clojure-mave

Problem with clojure-maven-plugin and ns metadata

2009-09-07 Thread Stuart Sierra
Hi Mark, I like your clojure-maven-plugin, but I discovered a problem with 1.0. If a namespace declaration has metadata, like this: (ns #^{:doc "This is my namespace."} my.namespace) The the plugin fails to read the ns name. You get an error message like "Cannot find file __init.cla

Re: c.c and IBM JDK?

2009-09-07 Thread Michael Reid
On Mon, Sep 7, 2009 at 5:37 AM, David Andrews wrote: > > > triddell wrote: >> This patch fixed the issue for me on the IBM JDK. > > Sadly, not for me!  (IBM 1.5.0) c/c/pprint/ColumnWriter still fails > with: >  [java] java.lang.ClassFormatError: (clojure/contrib/pprint/ > ColumnWriter) field name

best way to make use of association lists

2009-09-07 Thread Conrad
Hi everyone! I have some data that consists of key/value pairs, but that need to maintain their order, in terms of when they were added to the list. In most lisps you'd do this with an association list, with a performance penalty of course if the alist gets too large. I was wondering if there's a

Re: for those who just can't get enough of monads

2009-09-07 Thread ronen
Thank for the link +2 I think that Java & C# languages (not the platforms) are not the places for monads (or functional programming in that respect). As for the "success" of ideas, not long ago functional languages them- selfs were thought of as too academic for practical use (multicore change all

VimClojure on Windows (problem + solution)

2009-09-07 Thread Niels Aan de Brugh
Just a little message to put this information online. Sorry if it's a tad off-topic. If you're look at the following error message while using VimClojure on MS Windows: Error detected while processing function 112..vimclojure#ExecuteNail..vimclojure#ExecuteNailWithInput: line 19: Couldn't exec

Re: dynamic :use

2009-09-07 Thread John Harrop
Or, you can go the opposite way and write a macro that expands into the appropriate ns form. This will work if the information you need from *db-adapter* is there by macroexpansion time. A macro that does a similar job to ns, but adds conditional features to the ns "DSL", can wrap and generalize w

Compiling a namespace causes subsequent uses of it to fail.

2009-09-07 Thread philip.hazel...@gmail.com
(ns testcomp) (var-get (or (ns-resolve *ns* 'foo) (intern *ns* 'foo :foo))) ;; foo ;(1) ;; (println foo) ;(2) ;; (do foo 3);(3) ;; (fn [] foo) ;(4) ;; ((fn [] foo)) ;(5) ;; ((fn [] (println foo))) ;(6) With

Re: Tight loop performance

2009-09-07 Thread Christophe Grand
Hello, On Mon, Sep 7, 2009 at 7:36 PM, Jonathan Smith wrote: > > Are we sure that it is the aset-* operation that is causing a slowdown > and not the fact that the aset-* operations are not being inlined, > whereas the regular aset operation is? aset-* uses java.lang.reflect.Array and is really

[ANN] Clojure quickstart maven archetype

2009-09-07 Thread Scott Fleckenstein
URL: http://github.com/nullstyle/clojure-quickstart/tree/master Hi all, As a little weekend project and something to spur me to start learning maven, I put together a simple little clojure quickstart archetype. It sets you up a hello world command line application from which you can build ou

clojure-stub

2009-09-07 Thread Nurullah Akkaya
Hi, I have created a build.xml file to setup the directory structure and download the required jars. To have a running clojure application. All the required class path settings are taken care of inside the xml file, so you can have a running hello world jar in a couple of second. It is loc

Re: Tight loop performance

2009-09-07 Thread Jonathan Smith
Are we sure that it is the aset-* operation that is causing a slowdown and not the fact that the aset-* operations are not being inlined, whereas the regular aset operation is? If so, the aset-* ops might be faster, and just in need of a small update! A lot of the time when something is slower t

Re: dynamic :use

2009-09-07 Thread Chouser
On Mon, Sep 7, 2009 at 1:17 AM, Cliff Wells wrote: > > What I've tried (no laughing!) is this bit of code: > > (ns site.database >  (:use [compojure]) >  (:use [clojure.contrib.sql]) >  (:use [site.setup]) > >  (if (= *db-adapter* "mysql") >    (:use [site.adapters.mysql :as adapter])) >  (if (= *

Re: Tight loop performance

2009-09-07 Thread B Smith-Mannschott
> On Sep 7, 4:27 pm, B Smith-Mannschott wrote: [snip] >> >> Questions about how best to optimize clojure code to approach java >> performance have come up with fair regularity in the past. You might >> find some good ideas if you search through the archives a bit. >> >> That said, Clojure is a dy

Re: Tight loop performance

2009-09-07 Thread rivercheng
Hi, icemaze: With trying the following code, I found now Clojure is only around 15 times slower than Java. (java6 -server) "Elapsed time: 76.134661 msecs" "Elapsed time: 9.509398 msecs" "Elapsed time: 15.137116 msecs" "Elapsed time: 1.827812 msecs" "Elapsed time: 14.477701 msecs" "Elapsed time:

dynamic :use

2009-09-07 Thread Cliff Wells
Hi, I'm new to Clojure (and Lisp-type languages in general) and I've never used Java... in short, I have a steep learning curve littered with rocks and nails. I also don't know whether it's a good thing that I have long experience with Python and C :-P In any case, as a first project, I'm tryi

Re: Tight loop performance

2009-09-07 Thread rivercheng
Due to Clojure's extremely easy integration with Java, your suggestion makes a lot of sense. But there's still a problem: it requires everyone learns Clojure has to know Java (not only the platform, but also the syntax). Moreover, once we combine the compiled language and script language (just lik

Re: Anyone else working on a Common Lisp style "loop"?

2009-09-07 Thread Richard Newman
> +1 for a Clojure port of Iterate; it's a fantastic library. I believe it's also completely specified, which is not the case for LOOP. LOOP is a little like English in that regard... very powerful, but time flies like an arrow, and fruit flies like a banana! --~--~-~--~~

Re: Anyone else working on a Common Lisp style "loop"?

2009-09-07 Thread Baishampayan Ghose
>> Heh, I've always wanted one of these. Anyways, I think that instead of >> emulating loop , you should try to somewhat emulate iterate. >> http://common-lisp.net/project/iterate/ > > Good point! I only used Iterate a couple times, and now I'm reading up > more seriously on it... I think I can ke

Re: Anyone else working on a Common Lisp style "loop"?

2009-09-07 Thread Tayssir John Gabbour
On Sep 7, 2:51 pm, Gorsal wrote: > Heh, I've always wanted one of these. Anyways, I think that instead of > emulating loop , you should try to somewhat emulate iterate. > http://common-lisp.net/project/iterate/ Good point! I only used Iterate a couple times, and now I'm reading up more seriously

Re: from OO to Lisp style (a blog post)

2009-09-07 Thread Jonathan Smith
Just out of curiosity, is there any technical reason that you decided to use signals instead of passing closures? (Modularity; Efficiency; more idiomatic to Java?) On Sep 6, 5:29 am, rb wrote: > On Sep 4, 8:30 pm, Jonathan Smith wrote: > > > Hi Ralph, > > > First off, nice post! We need more o

Re: Another Clojure Box - Version 1.4

2009-09-07 Thread Darmac
My response is inline too! > > Be sure that: > > - the REPL it's working fine (if it let you work normally then it's > > fine). > > I am not sure if I have found the REPL in the ACB yet. Is it the > WinCommand "Clojure 1.0" tab you are talking about? How do I setup ACB > the first time? Yes. Th

Re: Anyone else working on a Common Lisp style "loop"?

2009-09-07 Thread Gorsal
Heh, I've always wanted one of these. Anyways, I think that instead of emulating loop , you should try to somewhat emulate iterate. You would need a code walker, though, because you probably wouldn't want to use brackets for all the special case loop constructs. Is there one for clojure? I don't k

Anyone else working on a Common Lisp style "loop"?

2009-09-07 Thread Tayssir John Gabbour
Hi! Is anyone else working on a Common Lisp style "loop"? I'd hate to duplicate effort. I wrote one yesterday, though I still have to read that stuff on how to decently package a lib. ;) http://github.com/tayssir/cl-loop/tree/master (I might not have written this, but I couldn't figure out a p

Re: Tight loop performance

2009-09-07 Thread icemaze
@Christophe: thanks, your hint helped. @B Smith-Mannschott: > Questions about how best to optimize clojure code to approach java > performance have come up with fair regularity in the past. You might > find some good ideas if you search through the archives a bit. I see. As I said before (OP),

Re: c.c and IBM JDK?

2009-09-07 Thread David Andrews
triddell wrote: > This patch fixed the issue for me on the IBM JDK. Sadly, not for me! (IBM 1.5.0) c/c/pprint/ColumnWriter still fails with: [java] java.lang.ClassFormatError: (clojure/contrib/pprint/ ColumnWriter) field name is invalid at offset=0 (ColumnWriter.clj:36) ... during contrib bu

Re: Tight loop performance

2009-09-07 Thread Nicolas Oury
On Sun, 6 Sep 2009 07:54:33 -0700 (PDT) Andy Fingerhut wrote: > > Is there any reason to keep aset-* functions around in Clojure? I > guess backwards compatibility? > > It definitely seems worth flagging them when *warn-on-reflection* is > true, in a similar way to other warnings it enables.

Re: Tight loop performance

2009-09-07 Thread B Smith-Mannschott
On Sun, Sep 6, 2009 at 16:29, icemaze wrote: > > Hello! > > First of all, let me congratulate with the devs for their great work: > I've been using Clojure for just a couple of weeks and I had a lot of > fun learning it and experimenting with it. > I'm starting a concurrency-heavy project and I fe