Re: Help to optimize palindrome search from input file

2010-10-20 Thread siddarth shankar
someone posted a 200,000 char test-string: http://pastebin.com/raw.php?i=a8veAND3 (doesn't view properly in chrome, view-source and save) and the previous code failed pretty hard.. so, new approach - one pass has all the information on where each character occurs. so, create a map with each

Re: Let usage question

2010-10-20 Thread Tom Faulhaber
Dave, Yes, this is perfectly idiomatic and many people in Clojure (and also Haskell, for example) use let to help document how they're building up their computation. Stuart's suggestion is also good and it's largely a matter of personal preference which to use when. Of course, as you use

Re: clojure.java.*

2010-10-20 Thread Tom Faulhaber
Yup, it's an autodoc bug. I had fixed the bug, but forgot to pull the new version into the area where the autodoc robot runs. So the next time the robot ran, it undid the fixes. :( All fixed up now. Tom On Oct 19, 7:42 pm, Sean Corfield seancorfi...@gmail.com wrote: On Tue, Oct 19, 2010 at

clj-record Library: Handling Namespaces

2010-10-20 Thread Stefan Rohlfing
Dear Clojure group, I am currently reading chapter 9.1 MySQL clj-record of 'Clojure in Action'. clj-record seems pretty awesome, but I once again got lost in namespace jungle. Here is a concrete example: File 1:

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Michael Wood
On 20 October 2010 10:09, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: Dear Clojure group, I am currently reading chapter 9.1 MySQL clj-record of 'Clojure in Action'. clj-record seems pretty awesome, but I once again got lost in namespace jungle. Here is a concrete example:

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Stefan Rohlfing
The name 'user' is taken from an example in the book. The author executes the code at the REPL like this: (require '(active-record [user :as user])) user= (user/create {:login rob :first_name Robert :last_name Berger

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Meikel Brandmeyer
Hi, On 20 Okt., 10:09, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: ;; EOF while reading ;;  [Thrown class java.lang.Exception] Are you sure, that you don't have some syntax error somewhere? Sincerely Meikel -- You received this message because you are subscribed to the Google Groups

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Stefan Rohlfing
You are right, there was a syntax error in charge.clj. However, after correcting the error I get the same error message as with the other namespace declaration: ;; No such var: user/create ;; [Thrown class java.lang.Exception] On Oct 20, 4:37 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi,

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Meikel Brandmeyer
Hi, On 20 Okt., 10:46, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: You are right, there was a syntax error in charge.clj. However, after correcting the error I get the same error message as with the other namespace declaration: Did you try the same with charge/create? Examples in books

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Stefan Rohlfing
Yes, I also tried charge/create. The error message is different, but it still does not work: ;; No such namespace: charge ;; [Thrown class java.lang.Exception] On Oct 20, 5:03 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 20 Okt., 10:46, Stefan Rohlfing stefan.rohlf...@gmail.com wrote:

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Meikel Brandmeyer
Hi, On 20 Okt., 11:09, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: Yes, I also tried charge/create. The error message is different, but it still does not work: More evidence for a problem with the user alias. Try a different one like (:require [active-record.user :as u]). Sincerely

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Stefan Rohlfing
Evaluating your suggested declaration: (ns active-record.program.core (:require [active-record.user :as u]) (:require [active-record.charge :as charge])) I get the following error message: ;; Unable to resolve symbol: user= in this context ;; [Thrown class java.lang.Exception] The

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Meikel Brandmeyer
Hi, On 20 Okt., 11:35, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: Evaluating your suggested declaration:  (ns active-record.program.core    (:require [active-record.user :as u])    (:require [active-record.charge :as charge])) I get the following error message: ;; Unable to

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Stefan Rohlfing
You were right again. I left a code snippet from the book in charge.clj and forgot to remove it later. Now everything seems to work fine, even when importing the active- record.user namespace as 'user': (ns

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Meikel Brandmeyer
Hi, On 20 Okt., 14:04, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: I really learned at lot about dealing with namespaces today. I hope you also learned a bit about error messages. ;) No such var: user/create: That means you get past the namespace declaration. Hence they load fine. But in

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Stefan Rohlfing
I apologize for presenting you with a moving target. That was definitely not my attention. I should have realized I messed up the content of the files but unfortunately had no clue what all these exceptions meant. Therefore I really appreciate your detailed description of the conclusion you draw

Re: Improving Contrib

2010-10-20 Thread Eric Schulte
Mike Meyer mwm-keyword-googlegroups.620...@mired.org writes: It was also more work than submitting patches looks to be for apache, django, gnu FWIW in gnu projects if your patch is 10 lines long then they do require you to go through a fairly lengthy attribution process.

Re: Java Source Indentation

2010-10-20 Thread David Jacobs
All right, I suppose I can accept that. I'm not quite at the point where I can fix bugs, but maybe that will happen soon. I do know that the more I use this language, the more I dig it. Thanks for the feedback, David On Oct 15, 7:24 am, Stuart Halloway stuart.hallo...@gmail.com wrote: It's all

ClojureDocs is in Beta

2010-10-20 Thread zkim
Hey All, ClojureDocs is now in beta, relevant info below. Site: http://clojuredocs.org Beta Info: http://clojuredocs.wordpress.com/2010/10/19/clojuredocs-beta/ Main Repo: http://github.com/zkim/clojuredocs Thanks, Zack. -- You received this message because you are subscribed to the Google

Re: Let usage question

2010-10-20 Thread Alan
I agree with Tom (and with Stuart). I tend to like using - when it's convenient, since all you're really doing is performing a list of transformations on a single object. However, the let is better documentation if that's ever going to matter. Not because it makes it easier to understand what

Re: Let usage question

2010-10-20 Thread lprefontaine
Hi, readability might be a concern but it's not the only criteria. a) Do you need to trace intermediate results ? Then you need a binding so you do not redo the work twice (presumably, I exclude memoized functions here). Of course if the code has some side effects, the choice is

Re: Let usage question

2010-10-20 Thread Alan
By the way, http://tinyurl.com/2a235cn is an example of your style of let being used in the Clojure source: the definition of defn itself. It's a little overdone and weird-looking, but the alternative of deeply nested forms would be much worse. I didn't notice your question about technical

Re: Let usage question

2010-10-20 Thread cej38
This question leads into something that I read in Joy of Clojure (page 161 in the latest MEAP edition): If you manage to hold onto the head of a sequence somewhere within a function, then that sequence will be prevented from being garbage collected. The simplest way to retain the head of sequence

Re: Let usage question

2010-10-20 Thread Alan
When you work with a lazy sequence, Clojure (java really) automatically garbage-collects elements you're done with. It can only be certain you're done with them if you no longer have any reference to them, direct or indirect. If you've bound the head of the sequence to a local, then you can still

Re: ClojureDocs is in Beta

2010-10-20 Thread Lee Hinman
On Wed, Oct 20, 2010 at 10:46 AM, zkim zachary@gmail.com wrote: Hey All, ClojureDocs is now in beta, relevant info below. Site:  http://clojuredocs.org Beta Info:  http://clojuredocs.wordpress.com/2010/10/19/clojuredocs-beta/ Main Repo:  http://github.com/zkim/clojuredocs Thanks,

Re: Let usage question

2010-10-20 Thread Dave Ray
Not only did my question get answered, but I learned several new things in the process. Thanks! Dave On Wed, Oct 20, 2010 at 1:52 PM, Alan a...@malloys.org wrote: When you work with a lazy sequence, Clojure (java really) automatically garbage-collects elements you're done with. It can only

Re: getting started with clojure

2010-10-20 Thread ishkabible
thanks guys, im at school right now so i cant really try anything out, i think im just going to use a text editor with coljure via command line.. yes i was using repl, later i found that i could edit full files by simply saving a new file but could not compile them, i think i will try using

Suspensions

2010-10-20 Thread Paul Richards
Hi,.. Having just completed reading Purely Functional Data Structures (Chris Okasaki), I'm keen to try things out in Clojure.. Something used fairly often in the book is the notion of a suspension. It's effectively a way to mark an expression as being lazy and memoized. I've not seen anything

Re: Suspensions

2010-10-20 Thread Albert Cardona
user= (doc future) - clojure.core/future ([ body]) Macro Takes a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet

Re: Let usage question

2010-10-20 Thread Rich Hickey
On Oct 20, 1:34 pm, cej38 junkerme...@gmail.com wrote: This question leads into something that I read in Joy of Clojure (page 161 in the latest MEAP edition): If you manage to hold onto the head of a sequence somewhere within a function, then that sequence will be prevented from being

Re: Suspensions

2010-10-20 Thread Alan
Augh no, future is not lazy; it's for multithreading. Try delay - it's identical to the (suspend) given by the OP. user= (time (def x (delay (Thread/sleep 1 Elapsed time: 0.256312 msecs #'user/x user= (time (force x)) Elapsed time: 1.19261 msecs See also promise/deliver: user= (def

Re: Suspensions

2010-10-20 Thread Paul Richards
On 20 October 2010 20:23, Alan a...@malloys.org wrote: Augh no, future is not lazy; it's for multithreading. Try delay - it's identical to the (suspend) given by the OP. user= (time (def x (delay (Thread/sleep 1 Elapsed time: 0.256312 msecs #'user/x user= (time (force x)) Elapsed

Re: Let usage question

2010-10-20 Thread cej38
great! good to know On Oct 20, 3:21 pm, Rich Hickey richhic...@gmail.com wrote: On Oct 20, 1:34 pm, cej38 junkerme...@gmail.com wrote: This question leads into something that I read in Joy of Clojure (page 161 in the latest MEAP edition): If you manage to hold onto the head of a

Misleading error message on incorrect if-let use

2010-10-20 Thread David Jagoe
Hi all, I noticed today (clojure 1.2) that using if-let incorrectly thusly: (if-let [a 1] (println 1) (println 2) (println 3)) Instead of e.g. (if-let [a 1] (println 1) (do (println 2) (println 3))) Results in this error if-let requires a vector for its binding [Thrown

Re: Suspensions

2010-10-20 Thread Paul Richards
On 20 October 2010 20:45, Paul Richards paul.richa...@gmail.com wrote: On 20 October 2010 20:23, Alan a...@malloys.org wrote: Augh no, future is not lazy; it's for multithreading. Try delay - it's identical to the (suspend) given by the OP. user= (time (def x (delay (Thread/sleep 1

Re: Misleading error message on incorrect if-let use

2010-10-20 Thread David Jagoe
Looks like its already done: https://www.assembla.com/spaces/clojure/tickets/103-gc-issue-99--incorrect-error-with-if-let On 20 October 2010 22:20, David Jagoe davidja...@gmail.com wrote: Hi all, I noticed today (clojure 1.2) that using if-let incorrectly thusly: (if-let [a 1]  (println 1)

Re: Suspensions

2010-10-20 Thread Paul Richards
On 20 October 2010 21:21, Paul Richards paul.richa...@gmail.com wrote: On 20 October 2010 20:45, Paul Richards paul.richa...@gmail.com wrote: On 20 October 2010 20:23, Alan a...@malloys.org wrote: Augh no, future is not lazy; it's for multithreading. Try delay - it's identical to the (suspend)

Re: Suspensions

2010-10-20 Thread Alan
You can use @x as shorthand for (force x) too, since delays implement IDeref. On Oct 20, 1:25 pm, Paul Richards paul.richa...@gmail.com wrote: On 20 October 2010 21:21, Paul Richards paul.richa...@gmail.com wrote: On 20 October 2010 20:45, Paul Richards paul.richa...@gmail.com wrote: On

Re: getting started with clojure

2010-10-20 Thread Eric Lavigne
The short answer is that it's okay to use Clojure directly. You don't need Leiningen. If you are familiar with C programming, the difference between the Clojure compiler and Leiningen is like the difference between GCC and Make. Using the compiler directly is fine when you have only one file of

Re: Improving Contrib

2010-10-20 Thread Mike Meyer
On Wed, 20 Oct 2010 09:59:26 -0600 Eric Schulte schulte.e...@gmail.com wrote: Mike Meyer mwm-keyword-googlegroups.620...@mired.org writes: It was also more work than submitting patches looks to be for apache, django, gnu FWIW in gnu projects if your patch is 10 lines long then they do

Re: Improving Contrib

2010-10-20 Thread Quzanti
I understand that contrib wasn't intended to be a standard library, but it inclusion in contrib did suggest to me that a library was being widely used (and tested) and is relatively stable, and that is there was a common problem, then contrib would likely have a library for it Then there is the

Re: getting started with clojure

2010-10-20 Thread Mike Meyer
On Wed, 20 Oct 2010 18:04:17 -0400 Eric Lavigne lavigne.e...@gmail.com wrote: The short answer is that it's okay to use Clojure directly. You don't need Leiningen. If you are familiar with C programming, the difference between the Clojure compiler and Leiningen is like the difference

Sandbar Dependencies Problem

2010-10-20 Thread nickikt
I want to make a little Webstuff with Clojure. Wanted to use Sandbar formes and looked at the blogpost http://formpluslogic.blogspot.com/2010/09/taming-html-forms-with-clojure.html. There is kind of a mismatch between blog, implementation and documentation. For the Blogpost i need something like

Re: Help to optimize palindrome search from input file

2010-10-20 Thread Kent
I took a different approach, not wildly clojurish, type-hinted, ugly, but also pretty fast. About 1.2ms on my machine (after about 10 runs so the JIT has done its magic). The approach is to look at each character, or pair of adjacent characters, as the potential center of a palindrome and then

Re: Let usage question

2010-10-20 Thread Michael Ossareh
On Wed, Oct 20, 2010 at 09:52, Alan a...@malloys.org wrote: I agree with Tom (and with Stuart). I tend to like using - when it's convenient, since all you're really doing is performing a list of transformations on a single object. However, the let is better documentation if that's ever going

Re: Sandbar Dependencies Problem

2010-10-20 Thread Brenton
Nickikt , All of the stuff covered in that blog post is in Sandbar 0.3.0- SNAPSHOT. You will need to add [sandbar 0.3.0-SNAPSHOT] as a dependency. There are also lots of working examples in the project on GitHub. http://github.com/brentonashworth/sandbar/tree/master/src/sandbar/example/

Re: ANN: Emacs auto-complete plugin for slime users

2010-10-20 Thread Paul Mooser
I was having this problem, and what solved it for me was to customize the ac-modes variable (using M-x customize-variable RET ac-modes RET) and adding slime-repl-mode to the list. Once I added this, auto- complete gets automatically enabled on my repl buffers as well. Give it a try! On Oct 17,

Re: Conj arrivals and Thursday night...

2010-10-20 Thread Alex Miller
The Revelytix crew will be in around dinner time on Thursday. I'm happy to spring for food during the hackathon courtesy of Strange Loop or take a group out to dinner - whatever happens to be convenient. Alex Miller -- You received this message because you are subscribed to the Google Groups