Performance tips for Clojure

2009-03-13 Thread Sergio
Hi! I have been programming in clojure for a few months now. I really like the language. Something that I have noted is that it is very easy to write slow Clojure code. After doing some programming and spending time optimizing things, I decided to write on my blog some points on how to write

Re: r994 UTF8 addition broke latin-1 characters (ISO-8859-1) - WAS: Re: Unicode, accented characters

2009-03-13 Thread max3000
Any news on this item? Does what I'm saying make sense? I understand most people who use clojure are probably English-speaking and couldn't care less about internationalization, but this has to be addressed if clojure is to get any semblance of semi-mainstream adoption. In fact, one of the

Re: Performance tips for Clojure

2009-03-13 Thread Chouser
On Fri, Mar 13, 2009 at 2:18 AM, Sergio bigmonac...@gmail.com wrote: There are a couple of obvious ones, but also some others that I haven't seen documented (like, map is much faster on lists than on vectors since rest is O(1) for lists). You're right that 'rest' is O(1) for lists, but it's

Re: r994 UTF8 addition broke latin-1 characters (ISO-8859-1) - WAS: Re: Unicode, accented characters

2009-03-13 Thread Michael Wood
On Fri, Mar 13, 2009 at 8:46 AM, max3000 maxime.lar...@gmail.com wrote: Any news on this item? Does what I'm saying make sense? I understand most people who use clojure are probably English-speaking and couldn't care less about internationalization, but this has to be addressed if clojure

Re: Performance tips for Clojure

2009-03-13 Thread Sergio
Sorry =( I am horribly mistaken I should have taken my time before posting.. But still, I really thought cons on vectors was O(n) base on PersistentVector.java, line 148 (The version I'm reading is not the current SVN head, so I don't know if it is that line for you) Here is the snippet:

Re: Miller-Rabin pseudo-primality test

2009-03-13 Thread Tassilo Horn
Jerry K jerryk...@gmail.com writes: Hi Jerry, Glad your problem is resolved. Miller-Rabin is quite zippy... and practical for real use. If you want a next cool exercise to take a crack at, the direction one often goes is to improve the speed of the underlying multiplications using the

Re: r994 UTF8 addition broke latin-1 characters (ISO-8859-1) - WAS: Re: Unicode, accented characters

2009-03-13 Thread max3000
I paste below what I got. It's doing something for sure, but just for *out* I think. Thanks. user= (println abcd) ����abcd nil user= (binding [*in* (new LineNumberingPushbackReader (new InputStreamReader System/in)) *out* (new OutputStreamWriter System/out)] (println

Re: What is Clojure NOT good for?

2009-03-13 Thread knubee
Is it fair to say that Clojure shines in algorithmic processing, string processing, concurrency management, but that there are better choices in other areas: not an answer, but a follow-on question: how well does clojure currently support multimedia programming? i realize it supports it to

Re: VimClojure 2

2009-03-13 Thread Yasuto TAKENAKA
In my environment, same error occurs ... although I have erased Gorilla and previous vimclojure packages. I install it using my installer script. If wrong, let me know. -- #!/bin/sh # installer.sh - a simple vimclojure installer. # Please rewrite CLOJURE, CLOJURECONTRIB and VIMCLOJUREHOME. #

Re: Performance tips for Clojure

2009-03-13 Thread Mark Engelberg
list doesn't do what you think it does. You've just created a list of one element. On Fri, Mar 13, 2009 at 12:10 AM, Sergio bigmonac...@gmail.com wrote: (def ls (list (range 100))) --~--~-~--~~~---~--~~ You received this message because you are subscribed

Re: VimClojure 2

2009-03-13 Thread Adrian Cuthbertson
I think the could be a problem in generating your path in .vimrc. Try... let vimclojure#NailgunClient='/your_path/vimclojure-2.0.0/ng' and don't forget also for .vimrc let g:clj_want_gorilla = 1 Rgds, Adrian. On Fri, Mar 13, 2009 at 2:09 AM, Yasuto TAKENAKA y.taken...@gmail.com wrote: In my

Re: VimClojure 2.0.0 released (merged with Gorilla)

2009-03-13 Thread MattH
Thanks Meikel, this is really useful! I noticed that the C-Up and C-Down key bindings used for the history navigation work fine in MacVim.app, but not from the terminal in OS X. So for any VimClojurians on OS X with the same problem, suggested workarounds: - use MacVim.app, or - add alternative

Re: Performance tips for Clojure

2009-03-13 Thread Christian Vest Hansen
On Fri, Mar 13, 2009 at 7:49 AM, Chouser chou...@gmail.com wrote: On Fri, Mar 13, 2009 at 2:18 AM, Sergio bigmonac...@gmail.com wrote: There are a couple of obvious ones, but also some others that I haven't seen documented (like, map is much faster on lists than on vectors since rest is

Re: Performance tips for Clojure

2009-03-13 Thread Christophe Grand
Christian Vest Hansen a écrit : I think that count is O(n) for lists, no? Count is O(1) for lists but O(n) for a chain of conses. Clojure user= (let [l (apply list (range 10))] (time (dotimes [_ 100] (count l Elapsed time: 169.710116 msecs nil user= (let [l (apply list (range

Re: VimClojure 2.0.0 released (merged with Gorilla)

2009-03-13 Thread Meikel Brandmeyer
Hi, Am 13.03.2009 um 05:51 schrieb rzeze...@gmail.com: 1) In the preview window it says Use \p to close this buffer!, but I have m LocalLeader mapped to ,. I'm guessing maybe you hardcoded this by accident? Yes. I should read the maplocalleader option to show the right key. Will be fixed.

Re: version of - short-circuiting on nil

2009-03-13 Thread Laurent PETIT
OK, so I think the consensus is on the names .?. and -? . No problem with me. I'm willing to write the patch, but which patch ? I mean, do these macros deserve their own file (maybe not) ? Maybe adding them to the existing clojure.contrib.macros ? Or else, I was thinking about creating a new file

Re: Speed issues vs. Python

2009-03-13 Thread André Thieme
On 12 Mrz., 07:48, tristan tristan.k...@gmail.com wrote: my clojure version http://github.com/tristan/project-euler-code/blob/4a17bc271b4b2743ee1... Not about speed, but about readability: (loop [c primes n #{}] (let [r (loop [b primes n n] (let [r (loop [a primes n n] ...))) You

Re: VimClojure 2.0.0 released (merged with Gorilla)

2009-03-13 Thread Meikel Brandmeyer
Hi, Am 13.03.2009 um 09:08 schrieb MattH: I noticed that the C-Up and C-Down key bindings used for the history navigation work fine in MacVim.app, but not from the terminal in OS X. I don't use Vim in a terminal anymore. The I don't do much testing there. So for any VimClojurians on OS

Re: r994 UTF8 addition broke latin-1 characters (ISO-8859-1) - WAS: Re: Unicode, accented characters

2009-03-13 Thread Christophe Grand
here is some background info on the change: http://groups.google.com/group/clojure/browse_thread/thread/123ef17d7c650018/e1da76a4a273aa5a max3000 a écrit : The default character set on WinXP (which I use) is windows-1252 (cp1252). Check out http://www.rgagnon.com/javadetails/java-0505.html.

Re: Speed issues vs. Python

2009-03-13 Thread Christophe Grand
It wont solve your performance problem but I think that your python code translates to: (defn f[a b c] (+ (* c c c c) (* b b b) (* a a))) (count (into #{} (for [c primes :while ( (f (first primes) (first primes) c) limit) b primes :while ( (f (first primes) b c) limit)

mocking in clojure

2009-03-13 Thread Korny Sietsma
Hi folks - are there any frameworks out there for mocking? Stubbing functions is pretty straightforward (and I see that fact comes with a stubbing function built in), but I'd really like something that can do mocking and mock expectations - something similar to stub, but with checking that the

Re: VimClojure 2

2009-03-13 Thread Mark Volkmann
On Fri, Mar 13, 2009 at 2:50 AM, Adrian Cuthbertson adrian.cuthbert...@gmail.com wrote: I think the could be a problem in generating your path in .vimrc. Try... let vimclojure#NailgunClient='/your_path/vimclojure-2.0.0/ng' and don't forget also for .vimrc let g:clj_want_gorilla = 1 I

Some help for tool builders...

2009-03-13 Thread Eric Thorsen
I come across some functions in clojure/core that are really useful in tool building but often are private. Is it possible to make these public? spread assert-args sigs libspec? root-resource root-directory Let me know and I'll submit a patch. Thanks, Eric

Re: VimClojure 2

2009-03-13 Thread Adrian Cuthbertson
Hi Mark, I'm also running on OSX 10.5. I couldn't get it working with the vim that comes with leopard - vim version 7.0.x I first downloaded and tried MacVim 7.2 from http://code.google.com/p/macvim/ but I couldn't unpack the .tbz files. I then tried the Vim.app 7.2 from

Re: Some help for tool builders...

2009-03-13 Thread Stephen C. Gilardi
On Mar 13, 2009, at 8:19 AM, Eric Thorsen wrote: I come across some functions in clojure/core that are really useful in tool building but often are private. Is it possible to make these public? An alternative to private that I've used in some of my contribs is to have a separate namespace

Re: VimClojure 2

2009-03-13 Thread Albert Cardona
Since this is a thread on VimClojure. First of all to say I am looking forward to vimclojure working perfectly. Here are some problems I don't understand: If I open a .clj file without the ng server running, it complains loudly and does not switch on syntax highlighting for clojure. Why no

Re: VimClojure 2

2009-03-13 Thread Mark Volkmann
On Fri, Mar 13, 2009 at 7:27 AM, Adrian Cuthbertson adrian.cuthbert...@gmail.com wrote: Hi Mark, I'm also running on OSX 10.5. I couldn't get it working with the vim that comes with leopard - vim version 7.0.x I first downloaded and tried MacVim 7.2 from http://code.google.com/p/macvim/ but

Re: 08 and 09 are invalid numbers, but 01 through 07 are fine?

2009-03-13 Thread Luke VanderHart
Well! You learn something new every day. Ironically, I knew about octal, but back in the day when I was learning Java, the book I was reading didn't have a typeface that distinguished O and 0 very well, and since I never had to use them I never was corrected. Interesting. Thanks! On Mar 12,

Re: Some help for tool builders...

2009-03-13 Thread pmf
On Mar 13, 1:19 pm, Eric Thorsen ethor...@enclojure.org wrote: I come across some functions in clojure/core that are really useful in tool building but often are private. Is it possible to make these public? I'm using the following hack to access private functions (for example generate-class

Re: 08 and 09 are invalid numbers, but 01 through 07 are fine?

2009-03-13 Thread Michael Wood
On Fri, Mar 13, 2009 at 2:14 PM, Luke VanderHart luke.vanderh...@gmail.com wrote: Well! You learn something new every day. Ironically, I knew about octal, but back in the day when I was learning Java, the book I was reading didn't have a typeface that distinguished O and 0 very well, and

Re: 08 and 09 are invalid numbers, but 01 through 07 are fine?

2009-03-13 Thread David Sletten
On Mar 13, 2009, at 3:07 AM, Michael Wood wrote: This is pretty standard behaviour. On the other hand, it's not universal. sbcl: * 07 7 * 08 8 Common Lisp uses a separate syntax for binary/octal/hex literals. Legal: #b1011, #o377, #xDEADBEEF, #36rZZZ (Base 36 anyone?) Illegal:

Re: VimClojure 2

2009-03-13 Thread Yasuto TAKENAKA
Do you try to run the command, ./ng de.kotka.vimclojure.nails.NamespaceOfFile ? The following is the result when I tried to run this after starting a ngserver: cd your-vimcljure-directory ./ng de.kotka.vimclojure.nails.NamespaceOfFile java.lang.ClassNotFoundException:

Re: VimClojure 2

2009-03-13 Thread Meikel Brandmeyer
Hi Albert, Am 13.03.2009 um 13:42 schrieb Albert Cardona: If I open a .clj file without the ng server running, it complains loudly and does not switch on syntax highlighting for clojure. Why no syntax on? This happens for me if I open a file via the NerdTree plugin. I'm not sure why this

Re: VimClojure 2

2009-03-13 Thread Meikel Brandmeyer
Hi, Am 13.03.2009 um 13:45 schrieb Mark Volkmann: Hi Mark, I'm also running on OSX 10.5. I couldn't get it working with the vim that comes with leopard - vim version 7.0.x So this casts a new light on the problem. It appears to be specific to the vim that is a standard part of Mac OS X.

Re: Some help for tool builders...

2009-03-13 Thread Christophe Grand
pmf a écrit : On Mar 13, 1:19 pm, Eric Thorsen ethor...@enclojure.org wrote: I come across some functions in clojure/core that are really useful in tool building but often are private. Is it possible to make these public? I'm using the following hack to access private functions

Re: VimClojure 2

2009-03-13 Thread Mark Feeney
I've been struggling with the same issues (on Windows, not that it appears to matter). The line 23 in the error means the 23rd line of the function vimclojure#ExecuteNailWithInput(nail, input, ...) in vimfiles/autoload/ vimclojure.vim. It's unrelated to the code you're trying to execute. I dug

Clojure code: reserve lists (parens) for forms? (canonical ns)

2009-03-13 Thread Stephen C. Gilardi
I've seen discussions over time suggesting that Clojure's readability is enhanced by having more bracketing characters in play that just parentheses. I agree with that. I recall Chouser (corrections welcome) noting that in Clojure code, parentheses are used primarily for forms

Re: Clojure code: reserve lists (parens) for forms? (canonical ns)

2009-03-13 Thread Stuart Sierra
On Mar 13, 10:05 am, Stephen C. Gilardi squee...@mac.com wrote: Should we consider changing the canonical form for ns to use vectors   for all of its sequential sub-forms? One thing to consider: ns is a bit special, because :import/:use/:require/:load mimic the syntax and behavior of the

Re: VimClojure 2

2009-03-13 Thread Albert Cardona
Hi Meikel, Thank you for the prompt response. I will point this out more clearly in the documentation. And future users will be greateful for that! VimClojure is looking great Meikel. Albert -- Albert Cardona http://albert.rierol.net

Re: VimClojure 2

2009-03-13 Thread Mark Volkmann
On Fri, Mar 13, 2009 at 8:45 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 13.03.2009 um 13:45 schrieb Mark Volkmann: Hi Mark, I'm also running on OSX 10.5. I couldn't get it working with the vim that comes with leopard - vim version 7.0.x So this casts a new light on the problem. It

Re: VimClojure 2

2009-03-13 Thread Meikel Brandmeyer
Hi, Am 13.03.2009 um 15:02 schrieb Mark Feeney: So you could try \rf, but for me this still doesn't quite work for me. If I have just one file: foo.clj (ns foo) (+ 1 1) I can't \ef it. I get the same line 23 error you get. If I \rf it I get: (clojure.core/load /foo)

Re: What is Clojure NOT good for?

2009-03-13 Thread opus111
Here's my experience... I was primarily interested in Clojure as a scripting language. I wanted a nice layer to control code written in Java. I had used Groovy successfully, but missed macros and an extensible syntax. I used to work at Lisp Machines, so I jumped on a LISP that compiled to the

resultset-seq - keywords corresponding to column names containing _

2009-03-13 Thread pc
Hi, Would it be better if resultset-seq mapped column names like ITEM_ID to :item-id rather than :item_id? I am using a variation of Itay Maman's Application Context Pattern which, among other things, keeps state in a map wrapped in a closure. I have a lot of keywords being passed around. that

Re: VimClojure 2

2009-03-13 Thread Meikel Brandmeyer
Hi, Am 13.03.2009 um 16:13 schrieb Mark Volkmann: The version of the Vim that my Mac uses when a launch it from a Terminal window isn't ancient. It's 7.2.22. It seems likely that the issue is related to configuration instead of the version of Vim being used. What happens if you try to use

Re: mocking in clojure

2009-03-13 Thread Matt Clark
test-expect actually only depends on test-is for its own tests, and I'm planning on breaking the tests out into their own file. I thought it was an interesting idea having the tests and code in the same file, but in practice it ended up being less attractive than anticipated. - Matt On Mar 13,

Re: mocking in clojure

2009-03-13 Thread Allen Rohner
Any other options out there? I posted a patch for test-is a while ago that never made it in, and I don't know why. http://groups.google.com/group/clojure/browse_frm/thread/883d4833f869f764/47a45325c8f29599?lnk=gstq=test-is+expect+patch#47a45325c8f29599 The patch handles creating stub

Re: mocking in clojure

2009-03-13 Thread Stuart Sierra
Hi Allen, Sorry I haven't kept up with this. I think, though, that it's best to have it as a standalone library in clojure-contrib, so that people can use it with other testing frameworks if they want to. -Stuart On Mar 13, 3:20 pm, Allen Rohner aroh...@gmail.com wrote: Any other options out

Re: mocking in clojure

2009-03-13 Thread Stephen C. Gilardi
On Mar 13, 2009, at 4:10 PM, Stuart Sierra wrote: Hi Allen, Sorry I haven't kept up with this. I think, though, that it's best to have it as a standalone library in clojure-contrib, so that people can use it with other testing frameworks if they want to. -Stuart Allen, I see you have a

error messages with clojure-mode.el?

2009-03-13 Thread Raoul Duke
hi, when i have a repl going and get errors, it says NO_SOURCE_FILE:0 so it is hard for newbie-me to figure out what i'm doing wrong in my syntax. does slime do something more helpful here? am i mis-diagnosing the issue? any other helpful thoughts? thanks!

Re: error messages with clojure-mode.el?

2009-03-13 Thread Raoul Duke
i just tried using (load-file foo.clj) to see if that loaded file line numbers, but the errors still say no source found zero sorry charlie. :-( On Fri, Mar 13, 2009 at 4:41 PM, Raoul Duke rao...@gmail.com wrote: hi, when i have a repl going and get errors, it says NO_SOURCE_FILE:0 so it is

errors?

2009-03-13 Thread Raoul Duke
hi, i'm up to date with the clojure jar. the error messages i get seem awfully terse and not particularly helpful in learning what i'm doing wrong. for example, with the code below, when i try (bs 0 (vector 1 2 3)) i get java.lang.ClassCastException: clojure.lang.LazilyPersistentVector

Re: errors?

2009-03-13 Thread James Reeves
On Mar 13, 11:50 pm, Raoul Duke rao...@gmail.com wrote: i'm up to date with the clojure jar. the error messages i get seem awfully terse and not particularly helpful in learning what i'm doing wrong. for example, with the code below, when i try (bs 0 (vector 1 2 3)) i get

Re: version of - short-circuiting on nil

2009-03-13 Thread Laurent PETIT
Issue 34 ( http://code.google.com/p/clojure-contrib/issues/detail?id=34 ) created with patch (both -? and .?. defined in clojure.contrib.core, with unit tests in clojure.contrib.core.tests -- Laurent 3/13 Laurent PETIT laurent.pe...@gmail.com OK, so I think the consensus is on the names .?.

Re: errors?

2009-03-13 Thread Stephen C. Gilardi
On Mar 13, 2009, at 7:50 PM, Raoul Duke wrote: i'm up to date with the clojure jar. the error messages i get seem awfully terse and not particularly helpful in learning what i'm doing wrong. for example, with the code below, when i try (bs 0 (vector 1 2 3)) i get java.lang.ClassCastException:

Re: What is Clojure NOT good for?

2009-03-13 Thread e
On Fri, Mar 13, 2009 at 11:31 AM, opus111 opus...@gmail.com wrote: Here's my experience... I was primarily interested in Clojure as a scripting language. I wanted a nice layer to control code written in Java. I had used Groovy successfully, but missed macros and an extensible syntax. I

Re: errors?

2009-03-13 Thread Raoul Duke
thanks, all, for the notes! i will try those out. sincerely. --~--~-~--~~~---~--~~ 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