Re: How to add an URL into the classpath?
Hello clojurians, It seems not to be able to control the whole classpath of my runtime. But my aim, compiling with a path given at runtime and execute it, has been achieved, with (.setContextClassLoader (Thread/currentThread) (DynamicClassLoader. (.getContextClassLoader (Thread/currentThread))) Details reported below. Regards, Yoshinori Kohyama $ cat project.clj (defproject dce 0.0.1 :description Dynamic Compling And Execution :dependencies [[org.clojure/clojure 1.3.0]] :main dce.core) $ cat src/dce/core.clj (ns dce.core (:import java.net.URL clojure.lang.DynamicClassLoader) (:gen-class)) (defn -main [abs-path target-ns args] (let [ccl (.getContextClassLoader (Thread/currentThread)) dcl (if (instance? DynamicClassLoader ccl) ccl (let [l (DynamicClassLoader. ccl)] (.setContextClassLoader (Thread/currentThread) l) l))] (.addURL dcl (URL. (str file:// abs-path /src/))) (.addURL dcl (URL. (str file:// abs-path /classes/))) (binding [*compile-path* (str abs-path /classes)] (compile (symbol target-ns))) (def f (future (apply (resolve (symbol (str target-ns /-main))) args))) (Thread/sleep 5000) (future-cancel f))) $ tree samples samples ├── classes └── src └── foo └── core.clj 3 directories, 1 file $ lein repl REPL started; server listening on localhost port 5997 dce.core= (-main (.getCanonicalPath (java.io.File. samples)) foo.core arg1 arg2) Foo: arg1 arg2 Foo: arg1 arg2 Foo: arg1 arg2 Foo: arg1 arg2 Foo: arg1 arg2 Foo: arg1 arg2 true dce.core= ^D $ tree samplessamples ├── classes │ └── foo │ ├── core$_main.class │ ├── core$loading__4505__auto__.class │ └── core__init.class └── src └── foo └── core.clj 4 directories, 4 files $ lein uberjar ... Created ... dce/dce-0.0.1-standalone.jar $ rm -Rf samples/classes/* $ tree samples samples ├── classes └── src └── foo └── core.clj 3 directories, 1 file $ java -jar dce-0.0.1-standalone.jar `pwd`/samples foo.core arg1 arg2 Foo: arg1 arg2 Foo: arg1 arg2 Foo: arg1 arg2 Foo: arg1 arg2 Foo: arg1 arg2 ^C $ tree samples samples ├── classes │ └── foo │ ├── core$_main.class │ ├── core$loading__4505__auto__.class │ └── core__init.class └── src └── foo └── core.clj 4 directories, 4 files -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How to add an URL into the classpath?
I forgot to show foo/core.clj $ cat samples/src/foo/core.clj (ns foo.core) (defn -main [ args] (loop [] (println Foo: (apply str (interpose args))) (Thread/sleep 1000) (recur))) -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: doc strings for both interfaces and concrete implementations
Warren Lynn wrn.l...@gmail.com writes: In general, all different versions of a function should somehow do the same thing, so with separate docstrings you'd need to repeat yourself. A good guideline is to write the big picture first, followed by the meaning of the different parameters. I agree the design should keep all implementations to do the same thing *conceptually*, as that is what an interface is for. However, I can imagine it is very common that a concrete implementation needs extra documentation for certain implementation specific things. [...] In summary, in my view, this is a very legitimate and basic need. I won't object, and the alter-meta! approach allows you to do that. Of course, it cannot provide documentation for the implementations, but the interface docs may be extended with impl docs incrementally at the location where the implementation is defined. That's at least better than nothing... Bye, Tassilo -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: help with lein-localrepo
Thanks, it is working now. Neither seems to work for me. To, my project.clj I tried adding both [goose 2.1.19] and [com.gravity/goose 2.1.19], but in the On Monday, July 30, 2012 4:07:12 AM UTC+5:45, Shantanu Kumar wrote: On Sunday, 29 July 2012 17:37:40 UTC+5:30, Samrat Man Singh wrote: I want to use goose(https://github.com/jiminoc/goose) in a Clojure project and found a StackOverflow answer that pointed me to lein-localrepo. However, I couldn't figure out how to use it. I did: lein localrepo install ../goose/target/goose-2.1.19.jar goose/goose 2.1.19 And lein locallrepo list does show goose, but I don't know how to use it inside the repository. `lein deps` gives me nothing, and I'm not sure how to require goose into the REPL or my core.clj. You should create a project (lein new foo) and include goose as a dependency in project.clj before you can use it. Make sure you are using the correct version of lein-localrepo based on the Leiningen version. Shantanu -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: help with lein-localrepo
Thanks, it's working now. On Monday, July 30, 2012 4:07:12 AM UTC+5:45, Shantanu Kumar wrote: On Sunday, 29 July 2012 17:37:40 UTC+5:30, Samrat Man Singh wrote: I want to use goose(https://github.com/jiminoc/goose) in a Clojure project and found a StackOverflow answer that pointed me to lein-localrepo. However, I couldn't figure out how to use it. I did: lein localrepo install ../goose/target/goose-2.1.19.jar goose/goose 2.1.19 And lein locallrepo list does show goose, but I don't know how to use it inside the repository. `lein deps` gives me nothing, and I'm not sure how to require goose into the REPL or my core.clj. You should create a project (lein new foo) and include goose as a dependency in project.clj before you can use it. Make sure you are using the correct version of lein-localrepo based on the Leiningen version. Shantanu -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Testing ClojureScript
I'm trying to run the tests for ClojureScirpt under Ubuntu 12.04. I installed libmozjs, set the spidermonkey_home variable then ran script/test and got this: tim@tim-desktop:~/clojurescript$ script/test V8_HOME not set, skipping V8 tests Testing with SpiderMonkey Error: unrecognized flag -m Try --help for options node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ ReferenceError: print is not defined at Object.anonymous (/home/tim/clojurescript/out/core-advanced-test.js:349:506) at Module._compile (module.js:441:26) at Object..js (module.js:459:10) at Module.load (module.js:348:32) at Function._load (module.js:308:12) at Array.0 (module.js:479:10) at EventEmitter._tickCallback (node.js:192:41) JSC_HOME not set, skipping JavaScriptCore tests Tested with $[ran+1] out of 3 possible js targets tim@tim-desktop:~/clojurescript$ cat script/test What's the best way to run tests under Ubuntu? Thanks, Timothy -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Experiences developing a crowdfunding site for open source projects in Clojure (from a Python background)
I got an error when I went to the link, you posted in the original post. On Monday, July 30, 2012 1:08:40 AM UTC+5:45, Aaron Lebo wrote: Hi Samrat. Could you explain how you are trying to access the site (address) and what is happening? I started out in noir, and ended up using a lot of the design patterns and validation library. I stopped using noir for two reasons: I like being able to see the routes of all of my urls on a single page (noir binds them to their function definition), and a lot of the tutorials out there concerning different libraries are based on raw Ring or Compojure. I didn't want to get stuck debugging some minor issue simply because I didn't understand the differences between using a library with noir/Compojure, which did happen once. I really enjoyed noir, though, particularly the validation, it is very clever, though as I said earlier I'd love it if it did conversion as well as validation. Using Compojure was a blast. It rarely got in the way, which, imo is what a routing framework should do. On the templating side I used Hiccup. That might be one of my favorite libraries in any language. I desire writing templates in Python because you are stuck opening and closing every brace. It is tedious and error-prone. Hiccup cuts down on that tremendously. div class=row div class=eight columns p id=testtest/p div id=yep class=four columns spanyep/span /div /div turns into: [:div.row [:div.eight.columns [:p#test test]] [:div#yep.four.columns [:span yep]]] You can't beat that. Notice particularly how easy it is to define ids and classes. Plus it is just Clojure, so you end being able to use the whole power of the language templating. On the db side I used korma. It beats the hell out of writing raw db statements, but it too stays out of the way. I really like the way that it just inserts joins as part of your result hash maps. (defentity profile) (defentity user (has-one profile)) (select user (where {:id (*user* :id)}) (with profile)) Something like that would automatically join profile to user and return a single hash map. It is a contrived example, but you get the gist. Only problem I had with it was that you end up writing by hand more complex stuff like unions. Not a big deal but you want the same convenience. On Sat, Jul 28, 2012 at 12:12 AM, Samrat Man Singh samratmansi...@gmail.com wrote: I can't access your site. Also, I wanted to ask whether you used Noir or used a lower-level option(Compojure,etc)? On Friday, July 27, 2012 1:44:46 AM UTC+5:45, Aaron Lebo wrote: Hello! Sometime around 2 and a half months ago, I started to work on a new project using Clojure. I've been using Python heavily for about 6 six years working for a small direct mail company and before that started programming with Ruby on Rails. This new project was something out of left field, so I had different options on what technology to use. I ended up choosing Clojure, and my work on the site has been my first real experience using a lisp, Clojure, and the JVM. I'd like to share my experiences and how that has differed with my previous Python work. Before that, I'd like to make a little plug for my site. It is called kodefund http://www.kodefund.com (www.kodefund.com). The basic idea is to take the familiar Kickstarter model but to really focus on applying that to open source development. I feel that previous crowdfunding efforts have shown that there is an interest by developers to fund projects that they are enthusiastic about. When this works, everyone wins: the developer working on the project can devote their full time and effort on the actual project and still make a living and others get the benefits of the open source software. I feel like it is preferable over selling licenses to proprietary software or other efforts. So, every project on kodefund is required to be open source. This differentiates it from other crowdfunding sites, and helps to apply a filter: you know what you are getting when you go there instead of seeing dozens of projects for unrelated stuff. One other difference is that you can also start a project which is more or less a reverse Kickstarter. This allows you to take an idea for a project or issue you want fixed, raise funding, and find someone who will actually implement the project. Other users get to submit applications and you choose from them to find the most capable candidate. Once you chose an application, that person takes over the project. Finally, one other push I want to make is to open up proprietary software. Maybe your company has written some software in-house, but there's no real incentive to release it. What if you could crowdfund the software, get paid to release it, and the open source community as a whole could benefit from that? I feel like crowdfunding and open source
Re:
On Sun, Jul 29, 2012 at 3:07 PM, John Holland jbholl...@gmail.com wrote: I'm doing some exercises in coding that are meant for Java but I'm doing them in Clojure. I'm stuck on this one. The goal is to return true if an array of ints contains two consecutive 2s. I figured I'd use Stuart Halloway's by-pairs function to turn the sequence into pairs of numbers and check for a pair that is 2,2. This code in has22 below works if pasted into the REPL and evaluated but as a function it always returns false. If anyone can explain my error to me it'd be great. ( defn by-pairs [coll] (let [take-pair (fn [c] (when (next c) (take 2 c)))] (when-let [pair (seq (take-pair coll))] (lazy-seq (cons pair (by-pairs (rest coll))) (defn has22 [a] (if (some true? (map #(= 2 (first %) (nth % 1)) (by-pairs [a]))) true false)) user (some true? (map #(= 2 (first %) (nth % 1)) (by-pairs [1 2 2 2 ]))) true user (has22 [1 2 2 2]) false In an effort to increase the net amount of perversity in the universe, I offer the following alternate solution: (defn has22 [a] (- (concat [] (map str a) []) (interpose ) (apply str) (re-find # 2 2 ) boolean)) ;-) // Ben -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Testing ClojureScript
Looks like Node.js is being aliased as SpiderMonkey. That won't work. I suggest installing V8 from source. I'll update the ClojureScript Github wiki with instructions for testing latest JavaScriptCore and SpiderMonkey. David On Monday, July 30, 2012, Timothy Baldridge wrote: I'm trying to run the tests for ClojureScirpt under Ubuntu 12.04. I installed libmozjs, set the spidermonkey_home variable then ran script/test and got this: tim@tim-desktop:~/clojurescript$ script/test V8_HOME not set, skipping V8 tests Testing with SpiderMonkey Error: unrecognized flag -m Try --help for options node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ ReferenceError: print is not defined at Object.anonymous (/home/tim/clojurescript/out/core-advanced-test.js:349:506) at Module._compile (module.js:441:26) at Object..js (module.js:459:10) at Module.load (module.js:348:32) at Function._load (module.js:308:12) at Array.0 (module.js:479:10) at EventEmitter._tickCallback (node.js:192:41) JSC_HOME not set, skipping JavaScriptCore tests Tested with $[ran+1] out of 3 possible js targets tim@tim-desktop:~/clojurescript$ cat script/test What's the best way to run tests under Ubuntu? Thanks, Timothy -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.comjavascript:_e({}, 'cvml', 'clojure@googlegroups.com'); Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com javascript:_e({}, 'cvml', 'clojure%2bunsubscr...@googlegroups.com'); For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re:
I really like the 'partition' technique. That said, as a non-expert, I find the recursive approach marginally easier to read: (defn has22 [coll] (when-let [s (seq coll)] (or (= 2 (first s) (second s)) (recur (rest s) In my microbenchmarks, the above technique runs about 5-10x faster for all sequences. Close enough that I suspect it is largely a matter of personal preference, but still slightly faster on my machine. As a footnote, using destructuring instead ran only about half as fast as the above code: (defn has22-destructing [coll] (when-let [[x xs] (seq coll)] (or (= 2 x (first xs)) (recur xs Not entirely sure why that would be. Best regards, -DeWitt On Sun, Jul 29, 2012 at 8:22 PM, Yoshinori Kohyama yykohy...@gmail.comwrote: Hi John, 'partition' will be useful for you, as Moritz pointed out. (partition 2 1 [1 2 3 4]) - ((1 2) (2 3) (3 4)) (partition 2 1 [1 2 2 4]) - ((1 2) (2 2) (2 4)) (partition 2 1 [1 2 2 2]) - ((1 2) (2 2) (2 2)) (some #(= % [2 2]) (partition 2 1 [1 2 3 4])) - nil (some #(= % [2 2]) (partition 2 1 [1 2 2 4])) - true (some #(= % [2 2]) (partition 2 1 [1 2 2 2])) - true (filter #(= % [2 2]) (partition 2 1 [1 2 3 4])) - () (filter #(= % [2 2]) (partition 2 1 [1 2 2 4])) - ((2 2)) (filter #(= % [2 2]) (partition 2 1 [1 2 2 2])) - ((2 2) (2 2)) I'm sorry I can't recognize whether you need a pair of 2s or two pairs of 2s. If you need one or more pairs of 2s, do (defn has22 [coll] (boolean (some #(= % [2 2]) (partition 2 1 coll (has22 [1 2 3 4]) - false (has22 [1 2 2 4]) - true (has22 [1 2 2 2]) - true If you need two or more pairs of 2s, do (defn has222 [coll] ( 1 (count (filter #(= % [2 2]) (partition 2 1 coll) (has222 [1 2 3 4]) - false (has222 [1 2 2 4]) - false (has222 [1 2 2 2]) - true Regards, Yoshinori Kohyama -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
A question on Clojure precision
I was testing some of the code in Miclael Fogus Chris Houser's The Joy of Clojure and found this: Clojure 1.4.0 user= (let [a (+ 0.1 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M)] (println (class a)) a) java.lang.Double 0. user= (let [b (+ 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1)] (println (class b)) b) java.lang.Double 1.0 user= Can anyone help by explaining why a and b are not equal? I figure it has something to do with the reduce1 function. Thanks! -Kevin -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re:
Another one. (The exception is for early termination) (def found! (Exception.)) (defn has22 [l] (try (reduce #(and (= 2 %2) (or (not %1) (throw found!))) false l) false (catch Exception e true))) -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: A question on Clojure precision
Hey Does the part about numbers: http://clojure.org/data_structures clear it up for you? From (source +) you should see that (+ 0.1 0.1M ...) is matched to (. clojure.lang.Numbers (add x y))) ; (. clojure.lang.Numbers (add 0.1 0.1M)) =0.2 and that (+ 0.1M 0.1M ...) is (. clojure.lang.Numbers (add 0.1M 0.1M)) =0.2M So maybe the contagious nature of numbers are biting somewhere - you should experiment around. [(+ 0.9 0.1) (+ 0.8 0.1) (+ 0.7 0.1)] [(+ 0.9 0.1M) (+ 0.8 0.1M) (+ 0.7 0.1M)] [(+ 0.9M 0.1) (+ 0.8M 0.1) (+ 0.7M 0.1)] [(+ 0.9M 0.1M) (+ 0.8M 0.1M) (+ 0.7M 0.1M)] https://en.wikipedia.org/wiki/Arithmetic_precision /Kevin On Mon, Jul 30, 2012 at 5:04 PM, grahamke kgraha...@gmail.com wrote: I was testing some of the code in Miclael Fogus Chris Houser's The Joy of Clojure and found this: Clojure 1.4.0 user= (let [a (+ 0.1 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M)] (println (class a)) a) java.lang.Double 0. user= (let [b (+ 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1)] (println (class b)) b) java.lang.Double 1.0 user= Can anyone help by explaining why a and b are not equal? I figure it has something to do with the reduce1 function. Thanks! -Kevin -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Experiences developing a crowdfunding site for open source projects in Clojure (from a Python background)
On Sunday, July 29, 2012 3:45:00 PM UTC-4, Aaron Lebo wrote: Here's PEP 8 as an example of what I'm talking about: http://www.python.org/dev/peps/pep-0008/ Perhaps this might be useful: http://dev.clojure.org/display/design/Library+Coding+Standards ---John -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojurians in the midlands (UK)
Jim, this is really great! I have joined the google group and I'm looking forward to the next meetup! Great! Welcome to the group! as the website suggests i will keep an eye on the time and place as it says it is not always fixed...too bad I missed the clojurescript talk :( Yep, the ClojureScript talk was a real classic :) Well, it was my first ClojureScript talk anyway... btw, have you talked about the reducers lib? It is the first thing on my list to explore as soon as I return back to Manchester... Nope, but we would all be very keen to hear a talk on reducers ;) In case you missed it, the next talk is on August 13th 2012 - An introduction to Applicative Functors in Haskell by Ian Murray. Simon -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Alternative to (or (:k1 m) (:k2 m))
Is there an elegant way to say '(or (:k1 m) (:k2 m)), without repeating m? Using a let can be awkward if the expression isn't already wrapped in one; '(apply #(or %1 %2) (map m [:k1 :k2])) is similarly bad. Hopefully there's something clever I'm missing; any ideas? -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Alternative to (or (:k1 m) (:k2 m))
(some identity ((juxt :k1 :k2) m)) is the first thing I can think of. On Tue, Jul 31, 2012 at 12:48 AM, Michael Gardner gardne...@gmail.com wrote: Is there an elegant way to say '(or (:k1 m) (:k2 m)), without repeating m? Using a let can be awkward if the expression isn't already wrapped in one; '(apply #(or %1 %2) (map m [:k1 :k2])) is similarly bad. Hopefully there's something clever I'm missing; any ideas? -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Alternative to (or (:k1 m) (:k2 m))
On Mon, Jul 30, 2012 at 6:55 PM, Moritz Ulrich ulrich.mor...@gmail.com wrote: (some identity ((juxt :k1 :k2) m)) is the first thing I can think of. For even more fun, try (some m [:k1 :k2]) :) --Aaron -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Alternative to (or (:k1 m) (:k2 m))
On Jul 30, 2012, at 6:08 PM, Aaron Cohen wrote: For even more fun, try (some m [:k1 :k2]) :) Wow, that's perfect. It even works with string keys! Thanks, guys. -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: Mongoika, a new Clojure MongoDB library
Have you taken a look at other libraries such as CongoMongo I used CongoMongo in the past, And decided I need a library with more features. This is why I wrote Mongoika. Monger also lets you work with query cursors as lazy sequences, uses Mongo shell syntax for queries with maps and supports a variety of GridFS operations. I had not seen Monger before. I have looked at it just now. It seems to be more mature than Mongoika. Here is a comparison of the features of the three libraries. I hope people will correct any mistakes, and point out any important features I have forgotten. https://docs.google.com/spreadsheet/ccc?key=0AjcJV_bAT0m_dHVPY0lZZlZvbElyVGZqNFF4bzJJVnc#gid=0 -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: Mongoika, a new Clojure MongoDB library
On Mon, Jul 30, 2012 at 5:12 PM, Tokusei NOBORIO t.nobo...@gmail.com wrote: Here is a comparison of the features of the three libraries. I hope people will correct any mistakes, and point out any important features I have forgotten. https://docs.google.com/spreadsheet/ccc?key=0AjcJV_bAT0m_dHVPY0lZZlZvbElyVGZqNFF4bzJJVnc#gid=0 CongoMongo definitely supports: * WriteConcern * GridFS * Map-Reduce Not sure what you mean by several other categories so it's hard to tell whether CongoMongo supports them or not. Multiple Connections? Depending on how you define this, CongoMongo may well qualify. Connection Pool? CongoMongo uses the Java driver which does connection pooling internally already. Indexing? CongoMongo has add-index! and drop-index! and can retrieve indexes on a collection. Heroku? Pretty sure folks are using CongoMongo on Heroku but I can't confirm that. CongoMongo's readme doesn't list a lot of the stuff it does but you can see tests for most of the things mentioned above here: https://github.com/aboekhoff/congomongo/blob/master/test/somnium/test/congomongo.clj Hope that helps? -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: Mongoika, a new Clojure MongoDB library
On Mon, Jul 30, 2012 at 5:12 PM, Tokusei NOBORIO t.nobo...@gmail.com wrote: I used CongoMongo in the past, And decided I need a library with more features. What features were missing? Always interested in making CongoMongo better - since there's a whole team of contributors :) It seems to be more mature than Mongoika. FWIW, CongoMongo has been around since October 2009. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: Mongoika, a new Clojure MongoDB library
Thank you for explaining this to me. I didn't know that CongoMongo had these features. I have updated the feature comparison spreadsheet. Is it okay now? Does CongoMongo have anything like Mongoika's map-after feature? https://github.com/yuushimizu/Mongoika 2012/7/31 Sean Corfield seancorfi...@gmail.com: On Mon, Jul 30, 2012 at 5:12 PM, Tokusei NOBORIO t.nobo...@gmail.com wrote: I used CongoMongo in the past, And decided I need a library with more features. What features were missing? Always interested in making CongoMongo better - since there's a whole team of contributors :) It seems to be more mature than Mongoika. FWIW, CongoMongo has been around since October 2009. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 登尾 徳誠(Tokusei Noborio) { ニャンパス株式会社: http://nyampass.com/ ニコ生: http://com.nicovideo.jp/community/co1281759 Blog: http://tnoborio.blogspot.com/ Twitter: http://twitter.com/tnoborio } -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
atom / swap! question
I am a newbie and was doing some exercises when I ran across something that I don't understand. I am trying to count the number of elements in an array less than 100. My first attempt didn't work. The counter returns 0 (let [a (atom 0) i (take-while (fn[x] (swap! a inc) ( x 100)) [1 2 3 4 5])] [@a i]) = [0 (1 2 3 4 5)] I am not getting any insight from the source http://clojuredocs.org/clojure_core/clojure.core/take-whileof 'take-while' too. The strange thing is, if I set a break-point, I can see that the atom is getting incremented. (let [a (atom 0) i (take-while (fn[x] (swap! a inc) *(swank.core/break) *( x 100)) [1 2 3 4 5])] [@a i]) whereas if I do this in a slightly more roundabout way, it works! (let [a (atom 0) i (reduce (fn[l in] (if (or (nil? (last l)) ( (last l) 100)) ((fn[] (swap! a inc) (conj l in))) l )) [] [1 2 3 4 5])] [@a i]) = [5 [1 2 3 4 5]] I tried reading docs, but I am unable to understand what is happening. If anyone could please point me in the right direction, it would be great. Thanks in advance Vinay -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
swap! and atom behavior
Hi, I am a clojure newbie. I was working through some examples when I discovered some behavior that I cant understand. swap! behavior changes with the context it is used in. If I put it in a 'take-while', swap! doesnt work : (let [a (atom 0) i (take-while (fn[x] (swap! a inc) (swank.core/break) ( x 100)) [1 2 3 4 5])] [@a i]) == [0 (1 2 3 4 5)] The strange thing is, the breakpoint shows swap! incrementing a, but it still becomes 0 in the end. A more roundabout way, works : (let [a (atom 0) i (reduce (fn[l in] (if (or (nil? (last l)) ( (last l) 100)) ((fn[] (swap! a inc) (conj l in))) l )) [] [1 2 3 4 5])] [@a i]) == [5 [1 2 3 4 5]] I could not get anything by looking at the source of take-while. Why is this behaving differently ? How does the counter get reset when using a take-while ? I feel as if I am missing something basic. Any help/pointers would be great. Thanks Vinay -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: swap! and atom behavior
The problem is that take-while is lazy, so it does not actually perform the taking operation until the lazy-seq it returns is realized, e.g. by being printed. So when your code binds the (take-while ...) expression to i, the anonymous function you provided is not yet being invoked, and thus the atom's value is not being incremented. Since your code dereferences the a atom before it forces evaluation of the i lazy-seq, it gets the value 0. The a atom's value will only be 5 after i has been fully realized, which happens later. So, for example, if you changed your code to this: (let [a (atom 0) i (take-while (fn[x] (swap! a inc) ( x 100)) [1 2 3 4 5])] (println i) (println @a)) You will see the result you expect, because println forces i to be fully realized, and thus a will be changed as a side-effect. In general, performing side-effecty operations inside lazy code is not usually advisable, because due to the nature of laziness, the results will not be what you'd expect if you were coming from a, say, imperative-language background. Perhaps someone else can provide a link to some good reading material for learning about laziness? -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re:
Hi Nicolas, The technique, using throw an Exception when succeeded in searching, strikes me! Not idiomatic but very practical. It's like a break in a loop of imperatives. I may use it somewhere. Thank you. Regards, Yoshinori Kohyama -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: Mongoika, a new Clojure MongoDB library
On Mon, Jul 30, 2012 at 7:14 PM, Tokusei NOBORIO t.nobo...@gmail.com wrote: I have updated the feature comparison spreadsheet. Is it okay now? Thanx. It's still says 'n' for connection pooling - but that's built into the Java driver that CongoMongo uses so I'm not sure how you're defining that feature? Does CongoMongo have anything like Mongoika's map-after feature? https://github.com/yuushimizu/Mongoika No, because it does not have a query DSL. It seems to me that a query DSL, composable queries and map-after are all facets of one feature - if you don't have a query DSL, you're not going to have any of the other things...? -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: JDBC Timezone Issue
On Fri, Jul 27, 2012 at 10:42 AM, Jestine Paul jestine.p...@gmail.com wrote: I have raised a JIRA issue (JDBC-35) regarding the timezones returned from the ResultSet getter method. http://dev.clojure.org/jira/browse/JDBC-35 I'm a bit surprised no one has responded to this. Maybe no one else is having this issue? I'd love to see some feedback on this. I have also attached a patch to this issue. http://dev.clojure.org/jira/secure/attachment/11394/resultset-timezone.diff I hope there are better solutions suggested. Given that the patch just provides a way for users to tell the library these columns are special, it seems like you might just as well map a column adjustment function over the result set yourself? It feels very clunky. It also looks like it can reorder columns. java.jdbc used to use structmap to preserve column order but now uses regular maps - although small maps use an array map which does in fact preserve column ordering for reasonable numbers of columns. That didn't seem to be particularly important for users at the time but gratuitous partitioning of columns seems unnecessary... Overall, I still think this problem arises because you're not following best practices for managing timezones which is to have all your servers operating on the same timezone and using NTP to sync times - but I really do want to hear some feedback from other java.jdbc users (which is why I haven't just closed the ticket). -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Alternative to (or (:k1 m) (:k2 m))
On Tue, Jul 31, 2012 at 1:08 AM, Aaron Cohen aa...@assonance.org wrote: On Mon, Jul 30, 2012 at 6:55 PM, Moritz Ulrich ulrich.mor...@gmail.com wrote: (some identity ((juxt :k1 :k2) m)) is the first thing I can think of. For even more fun, try (some m [:k1 :k2]) :) The flip side of this proposal is: ((some-fn :k1 :k2) m) Which takes advantage of the fact that keywords can be called as functions. That means it will only work for keyword keys, but the upshot is that it will work for arbitrary functions (not just keywords) and m need not be a map. See also every-pred, which -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Alternative to (or (:k1 m) (:k2 m))
On Tue, Jul 31, 2012 at 7:00 AM, Ben Smith-Mannschott bsmith.o...@gmail.com wrote: On Tue, Jul 31, 2012 at 1:08 AM, Aaron Cohen aa...@assonance.org wrote: On Mon, Jul 30, 2012 at 6:55 PM, Moritz Ulrich ulrich.mor...@gmail.com wrote: (some identity ((juxt :k1 :k2) m)) is the first thing I can think of. For even more fun, try (some m [:k1 :k2]) :) The flip side of this proposal is: ((some-fn :k1 :k2) m) Which takes advantage of the fact that keywords can be called as functions. That means it will only work for keyword keys, but the upshot is that it will work for arbitrary functions (not just keywords) and m need not be a map. See also every-pred, which ((my new truly ergonomic keyboard is taking some getting used to -- this is the second time I've mashed some keys and ended up sending a gmail message earlier than intended.)) See also every-pred, which complements some-fn. Oh, and see complement too. These three correspond to 'or', 'and' and 'not' respectively. // ben -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en