Re: ANN: Emacs auto-complete plugin for slime users
Hi, just yesterday I took a first look at auto-complete together with your slime auto completion sources. I'm encountering some Exceptions, though, If I'm in a .clj-buffer and start typing (clojure. and then wait for the auto completion to popup I see a list of possible completions like, e.g., clojure.set, clojure.xml and more, and then an Exception pops up: clojure.set [Thrown class java.lang.ClassNotFoundException] Restarts: 0: [QUIT] Quit to the SLIME top level 1: [ABORT] ABORT to SLIME level 0 Backtrace: 0: java.net.URLClassLoader$1.run(URLClassLoader.java:202) 1: java.security.AccessController.doPrivileged(Native Method) 2: java.net.URLClassLoader.findClass(URLClassLoader.java:190) 3: clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java: 58) 4: java.lang.ClassLoader.loadClass(ClassLoader.java:307) 5: java.lang.ClassLoader.loadClass(ClassLoader.java:248) 6: java.lang.Class.forName0(Native Method) 7: java.lang.Class.forName(Class.java:247) 8: clojure.lang.RT.classForName(RT.java:1566) 9: clojure.lang.Compiler.maybeResolveIn(Compiler.java:5700) 10: clojure.core$ns_resolve.invoke(core.clj:3380) 11: swank.commands.basic$describe_symbol_STAR_.invoke(basic.clj:184) 12: swank.commands.basic $eval880$documentation_symbol__881.invoke(basic.clj:201) 13: clojure.lang.Var.invoke(Var.java:365) 14: user$eval1927.invoke(NO_SOURCE_FILE) 15: clojure.lang.Compiler.eval(Compiler.java:5424) 16: clojure.lang.Compiler.eval(Compiler.java:5391) 17: clojure.core$eval.invoke(core.clj:2382) 18: swank.core$eval_in_emacs_package.invoke(core.clj:94) 19: swank.core$eval_for_emacs.invoke(core.clj:241) 20: clojure.lang.Var.invoke(Var.java:373) 21: clojure.lang.AFn.applyToHelper(AFn.java:169) 22: clojure.lang.Var.applyTo(Var.java:482) 23: clojure.core$apply.invoke(core.clj:540) 24: swank.core$eval_from_control.invoke(core.clj:101) 25: swank.core$sldb_loop$fn__401.invoke(core.clj:203) 26: swank.core$sldb_loop.invoke(core.clj:200) 27: swank.core$invoke_debugger.invoke(core.clj:216) 28: swank.core$sldb_debug.invoke(core.clj:220) 29: swank.core$eval_for_emacs.invoke(core.clj:279) 30: clojure.lang.Var.invoke(Var.java:373) 31: clojure.lang.AFn.applyToHelper(AFn.java:169) 32: clojure.lang.Var.applyTo(Var.java:482) 33: clojure.core$apply.invoke(core.clj:540) 34: swank.core$eval_from_control.invoke(core.clj:101) 35: swank.core$spawn_worker_thread$fn__455$fn__456.invoke(core.clj: 300) 36: clojure.lang.AFn.applyToHelper(AFn.java:159) 37: clojure.lang.AFn.applyTo(AFn.java:151) 38: clojure.core$apply.invoke(core.clj:540) 39: swank.core$spawn_worker_thread$fn__455.doInvoke(core.clj:296) 40: clojure.lang.RestFn.invoke(RestFn.java:398) 41: clojure.lang.AFn.run(AFn.java:24) 42: java.lang.Thread.run(Thread.java:619) Another one shows up if I hit TAB (bound to indent-for-tab-command) before the completion shows up I get a No message. [Thrown class java.lang.NullPointerException] Restarts: 0: [QUIT] Quit to the SLIME top level Backtrace: 0: clojure.lang.Compiler$FnMethod.parse(Compiler.java:4290) 1: clojure.lang.Compiler$FnExpr.parse(Compiler.java:3173) 2: clojure.lang.Compiler.analyzeSeq(Compiler.java:5367) 3: clojure.lang.Compiler.analyze(Compiler.java:5190) 4: clojure.lang.Compiler.analyze(Compiler.java:5151) 5: clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3057) 6: clojure.lang.Compiler.analyzeSeq(Compiler.java:5371) 7: clojure.lang.Compiler.analyze(Compiler.java:5190) 8: clojure.lang.Compiler.analyze(Compiler.java:5151) 9: clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:4670) 10: clojure.lang.Compiler$FnMethod.parse(Compiler.java:4328) 11: clojure.lang.Compiler$FnExpr.parse(Compiler.java:3173) 12: clojure.lang.Compiler.analyzeSeq(Compiler.java:5367) 13: clojure.lang.Compiler.analyze(Compiler.java:5190) 14: clojure.lang.Compiler.eval(Compiler.java:5421) 15: clojure.lang.Compiler.eval(Compiler.java:5391) 16: clojure.core$eval.invoke(core.clj:2382) 17: swank.core$eval_in_emacs_package.invoke(core.clj:94) 18: swank.core$eval_for_emacs.invoke(core.clj:241) 19: clojure.lang.Var.invoke(Var.java:373) 20: clojure.lang.AFn.applyToHelper(AFn.java:169) 21: clojure.lang.Var.applyTo(Var.java:482) 22: clojure.core$apply.invoke(core.clj:540) 23: swank.core$eval_from_control.invoke(core.clj:101) 24: swank.core$spawn_worker_thread$fn__455$fn__456.invoke(core.clj: 300) 25: clojure.lang.AFn.applyToHelper(AFn.java:159) 26: clojure.lang.AFn.applyTo(AFn.java:151) 27: clojure.core$apply.invoke(core.clj:540) 28: swank.core$spawn_worker_thread$fn__455.doInvoke(core.clj:296) 29: clojure.lang.RestFn.invoke(RestFn.java:398) 30: clojure.lang.AFn.run(AFn.java:24) 31: java.lang.Thread.run(Thread.java:619) Did anybody else see this? I can reproduce this at will and can easily test things if you want. Kind regards, Stefan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this gr
trouble getting library structure right: can't let files talk to each other
Hi all, I'm trying to write a library to perform some statistical and data mining analyses. Clojure has proven a great help here, especially with the incanter library. Writing the code has been kind of an "organic" process (read: no planning), and I ended up with different conceptual groups of functions all within one file. So it makes sense to split this up and start organizing it. Unfortunately, I am having trouble making the different files (and namespaces) talk to each other, and need some help. Let's say I have two parts in my analysis, each of which require quite a few underlying functions. I would ideally start up a repl and focus on just one analysis: playing with the data, making some graphs, ... I've created a leiningen project with "lein new my-important-project", to which I added two files in src: analysis-1.clj and analysis-2.clj. Directory structure: +- project.clj +- test | +- my-important-project | +- core.clj +- src +- my-important-project +- core.clj +- analysis-1.clj +- analysis-2.clj Let's say this is the contents for those 3 files in src/ (core.clj contains functions and constants that are necessary for both analyses): core.clj (ns my-important-project.core (:use [incanter core io stats charts] [somnium congomongo])) (mongo! :db "the-database") (def some-constant 3.141592) analysis-1.clj (ns my-important-project.analysis-1) (defn say-from-one [text] (println (str "from 1: " text))) analysis-2.clj (ns my-important-project.analysis-2) (defn say-from-two [text] (println (str "from 2: " text))) If I want to work on analysis 2, I'd start up the repl in the main directory created by lein (so one *up* from src) and type: user=> (ns '(my-important-project core analysis-2)) user=> (say-from-two "some text") But as you'd have guessed: this doesn't work. The (ns) returns the following error: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IObj (core.clj:1) I've tried different versions of the (ns) function, including a vector as its argument, periods instead of spaces, ... In addition: in the end I'd like to write a script that does the analysis automatically. So instead of going into the repl, I'd "cljr run" a clj file. What should the (ns) bit of that file look like? I've been searching the web for what I'm doing wrong, but haven't found the solution yet. It's quite frustrating to see so many discussions about namespaces, but not being able to solve this issue. Any help very much appreciated, jan. -- 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: trouble getting library structure right: can't let files talk to each other
2010/8/17 jandot : > Hi all, > > I'm trying to write a library to perform some statistical and data > mining analyses. Clojure has proven a great help here, especially with > the incanter library. Writing the code has been kind of an "organic" > process (read: no planning), and I ended up with different conceptual > groups of functions all within one file. So it makes sense to split > this up and start organizing it. > > Unfortunately, I am having trouble making the different files (and > namespaces) talk to each other, and need some help. > > Let's say I have two parts in my analysis, each of which require quite > a few underlying functions. I would ideally start up a repl and focus > on just one analysis: playing with the data, making some graphs, ... > > I've created a leiningen project with "lein new my-important-project", > to which I added two files in src: analysis-1.clj and analysis-2.clj. > Directory structure: > > +- project.clj > +- test > | +- my-important-project > | +- core.clj > +- src > +- my-important-project > +- core.clj > +- analysis-1.clj > +- analysis-2.clj > > Let's say this is the contents for those 3 files in src/ (core.clj > contains functions and constants that are necessary for both > analyses): > > core.clj > (ns my-important-project.core > (:use [incanter core io stats charts] > [somnium congomongo])) > (mongo! :db "the-database") > (def some-constant 3.141592) > > analysis-1.clj > (ns my-important-project.analysis-1) > (defn say-from-one [text] (println (str "from 1: " text))) > > analysis-2.clj > (ns my-important-project.analysis-2) > (defn say-from-two [text] (println (str "from 2: " text))) Here, the ns declaration looks right. > If I want to work on analysis 2, I'd start up the repl in the main > directory created by lein (so one *up* from src) and type: > > user=> (ns '(my-important-project core analysis-2)) > user=> (say-from-two "some text") ns is a macro normally used at the top of the source files. To force the code of a namespace/file to be loaded, call require (which, unlike ns, is a function and thus requires the args to be quoted): (require '(my-important-project core analysis-2)) At this point, you should be able to call say-from-to with its full name: my-important-project.analysis-2/say-from-two. You can use the :as option to make a shorter prefix if you like (see link below). If you want to play around inside the namespace, you can go into it by calling: (in-ns 'my-important-project.analysis-2) or simply use the ns macro: (ns my-important-project.analysis-2) You will see the prompt change when you do this and from here you should be able to call say-from-two directly. > But as you'd have guessed: this doesn't work. The (ns) returns the > following error: > java.lang.ClassCastException: java.lang.String cannot be cast to > clojure.lang.IObj (core.clj:1) > > I've tried different versions of the (ns) function, including a vector > as its argument, periods instead of spaces, ... > > In addition: in the end I'd like to write a script that does the > analysis automatically. So instead of going into the repl, I'd "cljr > run" a clj file. What should the (ns) bit of that file look like? > > I've been searching the web for what I'm doing wrong, but haven't > found the solution yet. It's quite frustrating to see so many > discussions about namespaces, but not being able to solve this issue. The ns macro and library conventions are described here: http://clojure.org/libs > Any help very much appreciated, > jan. The ns macro is pretty complex and unfortunately I don't have time to write longer about it right now. I hope this could at least get you started. // Rasmus -- 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: trouble getting library structure right: can't let files talk to each other
Hi, ns is not used to switch to a namespace. First require your namespace, then use in-ns to switch to it. (require 'my-important-project.analysis-2) (in-ns 'my-important-project.analysis-2) Hope this helps. Sincerely Meikel -- 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: Emacs auto-complete plugin for slime users
On 17 Aug 2010, at 09:38, Stefan Kamphausen wrote: > Hi, > > just yesterday I took a first look at auto-complete together with your > slime auto completion sources. > > I'm encountering some Exceptions, though, > > If I'm in a .clj-buffer and start typing > > (clojure. > > and then wait for the auto completion to popup I see a list of > possible completions like, e.g., clojure.set, clojure.xml and more, > and then an Exception pops up: That seems to be a slime/swank problem, related to accessing the documentation for a symbol corresponding to a namespace. In a clojure-mode buffer, use M-: to execute the following expression: (slime-eval '(swank:documentation-symbol "clojure.set")) This results in the same error. I'll cross-post to the swank-clojure list to see if anyone knows what might be going wrong. -Steve -- 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: trouble getting library structure right: can't let files talk to each other
Hi, On 17 Aug., 13:39, Rasmus Svensson wrote: > (in-ns 'my-important-project.analysis-2) > > or simply use the ns macro: > > (ns my-important-project.analysis-2) Please note, that these two are *not* equivalent! With ns: Clojure 1.1.0 user=> (ns foo.bar (:refer-clojure :exclude (map))) nil foo.bar=> (def map 5) #'foo.bar/map foo.bar=> (in-ns 'user) # user=> (ns foo.bar) java.lang.IllegalStateException: map already refers to: #'foo.bar/map in namespace: foo.bar (NO_SOURCE_FILE:4) With in-ns: Clojure 1.1.0 user=> (ns foo.bar (:refer-clojure :exclude (map))) nil foo.bar=> (def map 5) #'foo.bar/map foo.bar=> (in-ns 'user) # user=> (in-ns 'foo.bar) # ns should really only be used to define a namespace. Then you should use in-ns to switch namespaces in the Repl (or to ensure we are in the right namespace at the top of a file, which is sucked in via load). Sincerely Meikel -- 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: Emacs auto-complete plugin for slime users
On 17 Aug 2010, at 13:00, Steve Purcell wrote: > That seems to be a slime/swank problem, related to accessing the > documentation for a symbol corresponding to a namespace. In a clojure-mode > buffer, use M-: to execute the following expression: > > (slime-eval '(swank:documentation-symbol "clojure.set")) > > This results in the same error. I'll cross-post to the swank-clojure list to > see if anyone knows what might be going wrong. Underlying all this, the following clojure function call produces the error: (find-doc clojure.set) -Steve -- 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: trouble getting library structure right: can't let files talk to each other
Thanks Rasmus, Meikel, This does help a lot already. There still seems to be an issue with using some of the things, though. When I do (require '(my-important-project core analysis-2)) I would logically do (in-ns 'my-important-project.analysis-2) because that's where all the functions are that I actually have to call. I am then still able to print out the some-constant from core by (println my-important-project.core/some-constant) but it seems that this does not work for the congomongo connection to a mongodb database (also referred to in the core.clj file): (println (my-important-project.core/fetch-one :data)) ; => No such var: my-important-project.core/fetch-one For this to work I have to reference the underlying "somnium.congomongo" directly instead of my-important-project.core: (println (somnium.congomongo/fetch-one :data)) ; => works Is there a way to make "fetch-one" and "some-constant" available within the analysis-2 namespace using their unqualified names? What about defining the namespace at the top of the analysis-2.clj file like this? (ns my-important-project.analysis-2 (:use [my-important-project core])) and just saying (require '(my-important-project analysis-2)) in the repl (so without mentioning core)? This *does* make it possible to get to "some-constant" directly, but still no luck with the congomongo (fetch-one) function. I don't understand why... If congomongo is "used" within core and core is "used" within analysis-2, this does not mean that the congomongo functions are available in analysis-2 without explicit calling of congomongo? That would be unfortunate, because I'd have to start "using" congomongo in several places, as well as incanter and other libraries... jan. On Aug 17, 1:10 pm, Meikel Brandmeyer wrote: > Hi, > > On 17 Aug., 13:39, Rasmus Svensson wrote: > > > (in-ns 'my-important-project.analysis-2) > > > or simply use the ns macro: > > > (ns my-important-project.analysis-2) > > Please note, that these two are *not* equivalent! > > With ns: > > Clojure 1.1.0 > user=> (ns foo.bar (:refer-clojure :exclude (map))) > nil > foo.bar=> (def map 5) > #'foo.bar/map > foo.bar=> (in-ns 'user) > # > user=> (ns foo.bar) > java.lang.IllegalStateException: map already refers to: #'foo.bar/map > in namespace: foo.bar (NO_SOURCE_FILE:4) > > With in-ns: > Clojure 1.1.0 > user=> (ns foo.bar (:refer-clojure :exclude (map))) > nil > foo.bar=> (def map 5) > #'foo.bar/map > foo.bar=> (in-ns 'user) > # > user=> (in-ns 'foo.bar) > # > > ns should really only be used to define a namespace. Then you should > use in-ns to switch namespaces in the Repl (or to ensure we are in the > right namespace at the top of a file, which is sucked in via load). > > Sincerely > Meikel -- 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 useful function?
If you say so. I mean, I see that your example produces output different than I might expect, but that's a function of clojure's basic API - memoize will do the same thing: user> (def q (atom 1)) #'user/q user> (defn myinc [ignored] (swap! q inc)) #'user/myinc user> (def m (memoize myinc)) #'user/m user> (m 1) 2 user> (m 1) 2 user> (m 2) 3 user> (m '(:a)) 4 user> (m '(:a)) 4 user> (m [:a]) 4 Obviously you shouldn't use memoize for a function like myinc, which isn't referentially transparent; I'm just using it to demonstrate whether memoize returns a saved result or calls myinc. If clojure says that [:a] and '(:a) are equal then you can't have them as two separate keys in a hash; I don't see the problem with this. If you want to do this with two arguments that are equal, you can use a vector instead: (map vector x (map class x)). Either way it's a convenient wheel that has probably been invented too many times. On Aug 16, 3:05 pm, wwmorgan wrote: > Sorry for the double-post. group-by actually maps outputs to inputs. > But you can run into trouble even with referentially transparent > functions, because of Clojure's equality semantics: > > user=> (def x [(list :a) (vector :a)]) > #'user/x > user=> (zipmap x (map class x)) > {(:a) clojure.lang.PersistentVector} > > - Will Morgan > > On Aug 16, 5:52 pm, wwmorgan wrote: > > > Note that if f is not referentially transparent, you can get different > > results depending on the order in which the collection is traversed, > > for unordered collections. See the API function group-by. It makes > > this behavior explicit by mapping each input argument to a vector of > > output arguments, in the same order as their corresponding inputs were > > traversed. > > > - Will Morgan > > > On Aug 16, 3:31 am, Alan wrote: > > > > (defn apply-keys [f ks] > > > (zipmap ks (map f ks))) > > > > Trivial to write, but it can be quite useful. For example: > > > (defn whatever [arg] > > > (let [some-list (make-list-from arg) > > > mapped (map myfunc some-list)] > > > (zipmap some-list mapped))) > > > > compared to > > > > (defn whatever [arg] > > > (apply-keys myfunc (make-list-from arg))) > > > > I was working on my project and found myself doing this fairly often; > > > I searched high and low in clojure.core and clojure.contrib but > > > couldn't find anything similar. This amazed me, because it seems so > > > common and generic that I assumed clojure would do it for me. If this > > > isn't already in a standard library, I'd like to see it added. I'm > > > happy to give it away to someone who maintains a package that would > > > "fit" this function, or if someone wants to explain to me how to add > > > my own package I'm willing to do that. > > > > Does this seem useful to anyone else? > > -- 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 useful function?
Double-posting myself, here, just to join the fun. You can generalize if you don't always want the same behavior: user> (defn apply-by [glue] (fn [f keys] (glue keys (map f keys #'user/apply-by user> ((apply-by zipmap) inc (range 5)) {4 5, 3 4, 2 3, 1 2, 0 1} user> ((apply-by (partial map vector)) inc (range 5)) ([0 1] [1 2] [2 3] [3 4] [4 5]) On Aug 16, 3:05 pm, wwmorgan wrote: > Sorry for the double-post. group-by actually maps outputs to inputs. > But you can run into trouble even with referentially transparent > functions, because of Clojure's equality semantics: > > user=> (def x [(list :a) (vector :a)]) > #'user/x > user=> (zipmap x (map class x)) > {(:a) clojure.lang.PersistentVector} > > - Will Morgan > > On Aug 16, 5:52 pm, wwmorgan wrote: > > > Note that if f is not referentially transparent, you can get different > > results depending on the order in which the collection is traversed, > > for unordered collections. See the API function group-by. It makes > > this behavior explicit by mapping each input argument to a vector of > > output arguments, in the same order as their corresponding inputs were > > traversed. > > > - Will Morgan > > > On Aug 16, 3:31 am, Alan wrote: > > > > (defn apply-keys [f ks] > > > (zipmap ks (map f ks))) > > > > Trivial to write, but it can be quite useful. For example: > > > (defn whatever [arg] > > > (let [some-list (make-list-from arg) > > > mapped (map myfunc some-list)] > > > (zipmap some-list mapped))) > > > > compared to > > > > (defn whatever [arg] > > > (apply-keys myfunc (make-list-from arg))) > > > > I was working on my project and found myself doing this fairly often; > > > I searched high and low in clojure.core and clojure.contrib but > > > couldn't find anything similar. This amazed me, because it seems so > > > common and generic that I assumed clojure would do it for me. If this > > > isn't already in a standard library, I'd like to see it added. I'm > > > happy to give it away to someone who maintains a package that would > > > "fit" this function, or if someone wants to explain to me how to add > > > my own package I'm willing to do that. > > > > Does this seem useful to anyone else? > > -- 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: async http client in clojure
I try to use 4 http clients for Clojure. They are all suck. Use Atpache Commons HTTP Client - it is best choice. On Aug 17, 8:12 am, leo wrote: > I am trying to understand how efficient it would be to use Clojure to > develop an asynchronous http client for my webapp instead of using > Java. Is there any specific way one can be better than the other? -- 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
question on clojure library coding standards
The standards doc on the wiki here: http://www.assembla.com/wiki/show/clojure/Clojure_Library_Coding_Standards Makes this recommendation: "Idiomatic code uses destructuring a lot. However, you should only destructure in the arg list if you want to communicate the substructure as part of the caller contract. Otherwise, destructure in a first-line let. Example: my snake code from the book fails this test, doing too much destructuring in arg lists." I'm not entirely sure how to interpret this. If a function is expecting a certain argument structure, isn't it always better to document that in a destructuring argument list? I'm finding that destructured signatures generally help me track my dataflow better. Can somebody elucidate this distinction a bit? -- 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: trouble getting library structure right: can't let files talk to each other
I feel a blog-post coming when I figured this out :-) On Aug 17, 2:26 pm, jandot wrote: > Thanks Rasmus, Meikel, > > This does help a lot already. > > There still seems to be an issue with using some of the things, > though. When I do > > (require '(my-important-project core analysis-2)) > > I would logically do (in-ns 'my-important-project.analysis-2) because > that's where all the functions are that I actually have to call. > > I am then still able to print out the some-constant from core by > > (println my-important-project.core/some-constant) > > but it seems that this does not work for the congomongo connection to > a mongodb database (also referred to in the core.clj file): > > (println (my-important-project.core/fetch-one :data)) ; => No such > var: my-important-project.core/fetch-one > > For this to work I have to reference the underlying > "somnium.congomongo" directly instead of my-important-project.core: > > (println (somnium.congomongo/fetch-one :data)) ; => works > > Is there a way to make "fetch-one" and "some-constant" available > within the analysis-2 namespace using their unqualified names? What > about defining the namespace at the top of the analysis-2.clj file > like this? > > (ns my-important-project.analysis-2 > (:use [my-important-project core])) > > and just saying (require '(my-important-project analysis-2)) in the > repl (so without mentioning core)? This *does* make it possible to get > to "some-constant" directly, but still no luck with the congomongo > (fetch-one) function. > > I don't understand why... If congomongo is "used" within core and core > is "used" within analysis-2, this does not mean that the congomongo > functions are available in analysis-2 without explicit calling of > congomongo? That would be unfortunate, because I'd have to start > "using" congomongo in several places, as well as incanter and other > libraries... > > jan. > > On Aug 17, 1:10 pm, Meikel Brandmeyer wrote: > > > > > Hi, > > > On 17 Aug., 13:39, Rasmus Svensson wrote: > > > > (in-ns 'my-important-project.analysis-2) > > > > or simply use the ns macro: > > > > (ns my-important-project.analysis-2) > > > Please note, that these two are *not* equivalent! > > > With ns: > > > Clojure 1.1.0 > > user=> (ns foo.bar (:refer-clojure :exclude (map))) > > nil > > foo.bar=> (def map 5) > > #'foo.bar/map > > foo.bar=> (in-ns 'user) > > # > > user=> (ns foo.bar) > > java.lang.IllegalStateException: map already refers to: #'foo.bar/map > > in namespace: foo.bar (NO_SOURCE_FILE:4) > > > With in-ns: > > Clojure 1.1.0 > > user=> (ns foo.bar (:refer-clojure :exclude (map))) > > nil > > foo.bar=> (def map 5) > > #'foo.bar/map > > foo.bar=> (in-ns 'user) > > # > > user=> (in-ns 'foo.bar) > > # > > > ns should really only be used to define a namespace. Then you should > > use in-ns to switch namespaces in the Repl (or to ensure we are in the > > right namespace at the top of a file, which is sucked in via load). > > > Sincerely > > Meikel -- 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
Lazy sequence for reading binary blocks from an input stream
I'm a few months into learning Clojure, and thought I'd put this function out for comment. I need to take a message digest of files on disk. I'm using a class in java.security to do this. The class uses an update method which accepts an array of bytes, and updates the hash. This calls for the common read-update pattern, but in Clojure. So I decided to try my hand at a lazy sequence of byte arrays: (defn stream-block-seq "A lazy sequence of blocks read from the given input-stream. Each block is returned as a separately allocated Java byte array. The maximum block size is given as the optional second argument; the default is 1024. A returned block may be shorter than the blocksize. Usually, the last block will be short. If the stream is exhausted, the result is nil." ([s blocksize] (let [buf (byte-array blocksize) readlen (.read s buf)] (if (>= readlen 0) (lazy-seq (let [newbuf (if (< readlen blocksize) (copy-array buf (byte-array readlen) readlen) buf)] (cons newbuf (stream-block-seq s blocksize))) ([s] (stream-block-seq s 1024))) Here's copy-array: (defn copy-array ([src srcpos dest destpos len] (do (System/arraycopy src srcpos dest destpos len) dest)) ([src dest len] (copy-array src 0 dest 0 len))) And here's the message-digest function that uses it: (defn message-digest "Generates a digest of the given input plaintext. Input must be a Java byte array, a Java ByteBuffer. hashname is optional and defaults to \"SHA-256\". The result is a vector of bytes. See http://download.oracle.com/javase/1.5.0/docs/guide/security/CryptoSpec.html#AppA for more information on the available hashes." ([input & opts] (let [opts (merge { :hash "SHA-256" :blocksize 32768 } (apply hash-map opts)) hashname (opts :hash) blocksize (opts :blocksize) md (MessageDigest/getInstance hashname)] (doseq [buf (stream-block-seq (input-stream input) blocksize)] (.update md buf)) (vec (.digest md) This all seems to work, and the performance seems acceptable: with a 32k buffer size, on my Core 2 Duo Macbook it takes about 50ms to hash a 1MiB file from disk, and 20ms from filesystem cache. However, I'm sure there's plenty of room for improvement. Is there a cleaner or more efficient way to do this? I found two previous threads which deal with similar puzzles -- * Resource cleanup when lazy sequences are finalized: http://groups.google.com/group/clojure/browse_thread/thread/caece062119de072/13c15c62c3397597?lnk=gst&q=lazy+buffered#13c15c62c3397597 * contrib mmap/duck_streams for binary data: http://groups.google.com/group/clojure/browse_thread/thread/f5239c7e66e7fb54/813b70b68081456d?lnk=gst&q=lazy+binary+stream#813b70b68081456d I must say that I find the lazy-sequence approach conceptually quite attractive here, but my taste may not yet be properly formed :) Comments welcome! thanks Michael Ashton. -- 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
defprotocol not working?
Hi there! I'm a completely new newbie in the clojure sphere - old dog in Java and a handful of other languages. But Clojure is my first (new) functional language, and I'm very excited about it - complements on your word Rich et. al.! :-) To learn clojure I've started with the (beta) book "Seven Languages in Seven Weeks" by Bruce Tate (pragprog.com) - great book by the way. He's got a section called "defrecord and protocols" where he's got this example: (ns tate.compass) (defprotocol Compass (direction [c]) (left [c]) (right [c])) The problem for me is this: When I run the code I get this error message from the "REPL": java.lang.Exception: Unable to resolve symbol: defprotocol in this context (NO_SOURCE_FILE:4) I'm using the stable version of clojure 1.1 and clojure contrib 1.1. I'm on OSX 10.6.4 and Apple JDK 1.6.0_20-b02-279-10M3065. Please help! I'm stuck, and I don't want to procede (for too long) until I figure out why I get this error ;) Thanks in advance. Kind regards, Henrik Mohr -- 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: Protocols and default method implementations
On Aug 12, 10:51 pm, Stuart Halloway wrote: > The other thing that you should consider is that protocols are the > contract for implementers, not the contract for callers. If you > change a contract for implementers, then the implementers *must* > change. > > Take your example of a function that has a reasonable default for > any object. Often such a function does not need to be part of the > contract for implementers (i.e. the protocol) at all. > > To make this more concrete, look at how protocols are used in > Clojure itself. InternalReduce is a contract for implementers, > consumers call reduce. Ditto for IOFactory: clients don't call it, > they call the functions reader, writer, etc. instead. Stuart, I just watched your presentation on Clojure 1.2 protocols at http://vimeo.com/11236603. Thanks for such a clear and informative presentation -- it was especially illuminating to be shown how InternalReduce is used. I certainly take your point that you generally will require implementors to provide all methods of a protocol -- because if you can provide a default, why are you asking clients to provide it in the protocol? However, in my last message I have an example of where an extension to the protocol of an optional method that is there for performance: it *can* be implemented slowly by default, but new clients might want to provide a faster version. It's kind of the same situation as InternalReduce: you can always reduce by treating the item as a seq (using the InternalReduce implementation for clojure.lang.ISeq), but InternalReduce can be re-implemented for specific types like java.lang.String as an optional accelerator. A new method can always be implemented on a new protocol, and a default provided for Object, but I guess I'm looking for the best of both worlds. In looking for examples in Java and COM of interface evolution, the instances that immediately come up are actually examples where implementors really do need to provide all methods, e.g. LayoutManager, LayoutManager2 (AWT), IProvideClassInfo, IProvideClassInfo2 (COM). So perhaps what I'm really asking for is better seen as an equivalent to a :default multimethod. Matthew. -- 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
Nil Coalesce
Hi All: First of all thanks for the replies to my last post the clojure community is great! I've been trying to find a succinct way to do the following. Given two sequences, product a new sequence which takes items from the first sequence unless null in which case it will take an item from the second, until the first sequence is exhausted. If nil is encountered in the first sequence and the second sequence is exhaused, nil will be returned: e.g. user> (nil-coalesce (nil 1 2 3 nil nil) (4 5)) (4 1 2 3 5 nil) I ended up with a scheme like natural recursion. I see two drawbacks. The result (presumably empty) must be passed in and the recursion will stack overflow for large sequences. I guess trampoline would fix this, but that seems a bit of a dirty trick and workaround until Java 7 gives us proper tail calls. Anyway I looked at partition and interleave but without a predicate, I don't see how to make either of these work. Anyone have a more elegant solution? (defn nil-coalesce [result maybe-nil replacements] (if (empty? maybe-nil) (if (empty? replacements) result nil) (let [x (first maybe-nil) xs (rest maybe-nil)] (if (nil? x) (recur (conj result (first replacements)) xs (rest replacements)) (recur (conj result x) xs replacements) -- 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: defprotocol not working?
defprotocol is a new feature of Clojure 1.2. A fantastic RC3 of this fantastic software is available. A good way to get it is to use the amazing Leiningen. On Tue, Aug 17, 2010 at 7:17 AM, Henrik Mohr wrote: > Hi there! > > I'm a completely new newbie in the clojure sphere - old dog in Java > and a handful of other languages. > But Clojure is my first (new) functional language, and I'm very > excited about it - complements on your word Rich et. al.! :-) > > To learn clojure I've started with the (beta) book "Seven Languages in > Seven Weeks" by Bruce Tate (pragprog.com) - great book by the way. > He's got a section called "defrecord and protocols" where he's got > this example: > > (ns tate.compass) > (defprotocol Compass (direction [c]) (left [c]) (right [c])) > > The problem for me is this: When I run the code I get this error > message from the "REPL": > java.lang.Exception: Unable to resolve symbol: defprotocol in this > context (NO_SOURCE_FILE:4) > > I'm using the stable version of clojure 1.1 and clojure contrib 1.1. > I'm on OSX 10.6.4 and Apple JDK 1.6.0_20-b02-279-10M3065. > > Please help! I'm stuck, and I don't want to procede (for too long) > until I figure out why I get this error ;) > > Thanks in advance. > > Kind regards, > Henrik Mohr > > -- > 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: Nil Coalesce
Yeah! Golf! user=> (defn nil-coalesce [coll replacements] (lazy-seq (when-let [s (seq coll)] (let [fst (first s)] (if (nil? fst) (cons (first replacements) (nil-coalesce (rest s) (rest replacements))) (cons fst (nil-coalesce (rest s) replacements))) #'user/nil-coalesce user=> (nil-coalesce [nil 1 2 3 nil nil] [4 5]) (4 1 2 3 5 nil) Sincerely Meikel -- 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: trouble getting library structure right: can't let files talk to each other
Hi, luckily use is not transitive. If you want to use congomongo from analysis-2 you have to do: (ns my-important-project.analysis-2 (:use somnium.congomongo)) (println (fetch-one :data)) or (nameing what you need explicitly; prefered) (ns my-important-project.analysis-2 (:use [somnium.congomongo :only (fetch-one)])) (println (fetch-one :data)) or (using an alias; also prefered over plain :use) (ns my-important-project.analysis-2 (:require [somnium.congomongo :as congo])) (println (congo/fetch-one :data)) Hope this helps. Sincerely Meikel -- 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
Clojure Web Programming group?
Hello, Personally I really like the way web development in Clojure is improving. Rather than huge frameworks there are different libraries that are coming together to form a useful toolset. Even the framework Conjure is lightweight and using general purpose libraries under the hood. One drawback of this library approach though is that it is daunting to beginners. Not only do newcomers have to choose what tools they want to use they have to find a way to fit them together. I've noticed that each library is being supported in their own group/ forum. This is fine for the well used libraries but less mainstream libraries have groups with little traffic. Also, since libraries need to interoperate it would be nice to have a place where library users and library developers are aware of other web development going on. I have developed three small libraries, mostly useful for web work, that could be of interest to other people. However, I don't want to start three different google groups which not only see no traffic but also separate some tools which can be best applied together. Because of this I was going to just have one group that supported all three. One idea I had though was to go one step further and start a Clojure web development group so that other developers of small libraries and users of them could go to one place for support and discussion. Would this be uncool or would it be useful? Saul -- 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: question on clojure library coding standards
Hi, On 17 Aug., 04:40, cageface wrote: > I'm not entirely sure how to interpret this. If a function is > expecting a certain argument structure, isn't it always better to > document that in a destructuring argument list? I'm finding that > destructured signatures generally help me track my dataflow better. > Can somebody elucidate this distinction a bit? It can overspecify things. Consider private fields of a record. The user should not fiddle with these, but you might well access them in your function. That you do so should be not of interest to the caller. Specifying it in the argument list would actually expose the caller to the details. So the details become part of the contract and you cannot change the internal workings of your library anymore. Sincerely Meikel -- 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: trouble getting library structure right: can't let files talk to each other
Thanks for the clarification. I think I have everything working now. j. On Aug 17, 3:14 pm, Meikel Brandmeyer wrote: > Hi, > > luckily use is not transitive. If you want to use congomongo from > analysis-2 you have to do: > > (ns my-important-project.analysis-2 > (:use somnium.congomongo)) > > (println (fetch-one :data)) > > or (nameing what you need explicitly; prefered) > > (ns my-important-project.analysis-2 > (:use [somnium.congomongo :only (fetch-one)])) > > (println (fetch-one :data)) > > or (using an alias; also prefered over plain :use) > > (ns my-important-project.analysis-2 > (:require [somnium.congomongo :as congo])) > > (println (congo/fetch-one :data)) > > Hope this helps. > > Sincerely > Meikel -- 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
Installing Clojure on OS X
Hey, How to install Clojure on Mac OS X? I googled the web, some use MacPorts, others write some shell scripts. Is there a -standard- way to install Clojure on OS X (if possible, please don't refer me to MacPorts)? Thanks all for help and time. -- 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: Clojure Web Programming group?
As someone new to web development (and clojure) in general, I'm +1 on this. I'm using compojure with ring and hiccup, and eventually targetting appengine. Of course there are lots of things to discuss with this, and way too many channels to effectively monitor. On Tue, Aug 17, 2010 at 10:15 AM, Saul Hazledine wrote: > Hello, > Personally I really like the way web development in Clojure is > improving. Rather than huge frameworks there are different libraries > that are coming together to form a useful toolset. Even the framework > Conjure is lightweight and using general purpose libraries under the > hood. > > One drawback of this library approach though is that it is daunting to > beginners. Not only do newcomers have to choose what tools they want > to use they have to find a way to fit them together. > > I've noticed that each library is being supported in their own group/ > forum. This is fine for the well used libraries but less mainstream > libraries have groups with little traffic. Also, since libraries need > to interoperate it would be nice to have a place where library users > and library developers are aware of other web development going on. > > I have developed three small libraries, mostly useful for web work, > that could be of interest to other people. However, I don't want to > start three different google groups which not only see no traffic but > also separate some tools which can be best applied together. Because > of this I was going to just have one group that supported all three. > > One idea I had though was to go one step further and start a Clojure > web development group so that other developers of small libraries and > users of them could go to one place for support and discussion. Would > this be uncool or would it be useful? > > Saul > > -- > 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 -- http://www.apgwoz.com -- 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: async http client in clojure
On 08/16/2010 04:12 PM, leo wrote: I am trying to understand how efficient it would be to use Clojure to develop an asynchronous http client for my webapp instead of using Java. Is there any specific way one can be better than the other? Bradford Cross of FlightCaster just wrote an excellent article on a framework he put together to make parallel HTTP requests: http://measuringmeasures.com/blog/2010/8/16/clojure-workers-and-large-scale-http-fetching.html The first part of the post does a nice job of outlining existing http libraries in Clojure. -- 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: question on clojure library coding standards
Different topic, but are you talking about fields in a record defined via defrecord? I thought those fields were not hidden (i.e. 'public'). "Encapsulation of information is folly" as it says here: http://clojure.org/datatypes. I agree with your point. Maybe a wee bit of encapsulation of information isn't always folly! Steve On Tue, Aug 17, 2010 at 9:29 AM, Meikel Brandmeyer wrote: > Hi, > > On 17 Aug., 04:40, cageface wrote: > > > I'm not entirely sure how to interpret this. If a function is > > expecting a certain argument structure, isn't it always better to > > document that in a destructuring argument list? I'm finding that > > destructured signatures generally help me track my dataflow better. > > Can somebody elucidate this distinction a bit? > > It can overspecify things. Consider private fields of a record. The > user should not fiddle with these, but you might well access them in > your function. That you do so should be not of interest to the caller. > Specifying it in the argument list would actually expose the caller to > the details. So the details become part of the contract and you cannot > change the internal workings of your library anymore. > > Sincerely > Meikel > > -- > 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: Installing Clojure on OS X
On Aug 17, 3:59 pm, HB wrote: > Hey, > How to install Clojure on Mac OS X? > I googled the web, some use MacPorts, others write some shell scripts. > Is there a -standard- way to install Clojure on OS X (if possible, > please don't refer me to MacPorts)? > Thanks all for help and time. I used a Mac in the past and I understand your frustration with MacPorts. I've not used Clojure on OSX but if you're bored you could try Homebrew which is an alternative to MacPorts. http://mxcl.github.com/homebrew/ Then: brew install clojure Hopefully you'll get a more useful replies later. Saul -- 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: async http client in clojure
Rather than just say they all suck, why not speak to the authors or submit issues/bug reports and explain why they suck. There is actually a clj-apache-http library that wraps Apache HTTP. On Aug 16, 7:36 pm, zahardzhan wrote: > I try to use 4 http clients for Clojure. They are all suck. Use > Atpache Commons HTTP Client - it is best choice. > > On Aug 17, 8:12 am, leo wrote: > > > > > I am trying to understand how efficient it would be to use Clojure to > > develop an asynchronous http client for my webapp instead of using > > Java. Is there any specific way one can be better than the other? -- 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: async http client in clojure
On Tue, Aug 17, 2010 at 11:18 AM, Rayne wrote: > Rather than just say they all suck, why not speak to the authors or > submit issues/bug reports and explain why they suck. There is actually > a clj-apache-http library that wraps Apache HTTP. Which I've found to be quite good and idiomatic. David -- 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: Installing Clojure on OS X
My first question would be how do you want to interact with clojure? Are you going to be using something like Netbeans, or emacs, or [shudder] vi? The answer really kinda depends on that. I really like Netbeans. The Enclojure plug-in works well. Also, all of these problems with using Macports, and scripts go away. Once you have Netbeans and Enclojure installed, you download the clojure and clojure.contrib jars, and point Netbeans at them and you are ready to go. -- 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: Installing Clojure on OS X
On Tue, Aug 17, 2010 at 10:59 AM, HB wrote: > Hey, > How to install Clojure on Mac OS X? > I googled the web, some use MacPorts, others write some shell scripts. > Is there a -standard- way to install Clojure on OS X (if possible, > please don't refer me to MacPorts)? > Thanks all for help and time. If you're just getting started and you're on OS X I whole-hearted recommend Cake. sudo gem install cake And you're pretty much good to go. You get an excellent autocompleting REPL. As long as you're not using Cake to design Rake style build tasks, it's pretty much interchangeable with Leiningen. Leiningen is excellent, but Cake benefits from "instant-on" REPLs as well as providing simpler integration for non-Emacs users (I'm working on a TextMate bundle). David -- 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 more general chunk-file
help please On Aug 16, 5:22 pm, cej38 wrote: > Hello, > I work with text files that are, at times, too large to read in all > at one time. In searching for a way to read in only part of the file > I came acrosshttp://meshy.org/2009/12/13/widefinder-2-with-clojure.html > > I am only interested in the chunk-file and read-lines-range functions. > > My problem is that I would like to change chunk-file, so that instead > of looking for the next line break, it would look for some regular > expression (to be given as part of the function call), and would then > report the position of the first character of every instance of that > regular expression. > > After working on this for a couple of days I am raising the white > flag. Is there someone that can help me with this? > > Thanks. -- 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: Clojure Web Programming group?
On Tue, Aug 17, 2010 at 10:15 AM, Saul Hazledine wrote: > > One idea I had though was to go one step further and start a Clojure > web development group so that other developers of small libraries and > users of them could go to one place for support and discussion. Would > this be uncool or would it be useful? > > Saul Not a bad idea if the library maintainers get behind it. I'm on the Ring, Compojure, Enlive, Aleph mailing lists :) David -- 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: Installing Clojure on OS X
Currently, I just to play around Clojure and TextMate. Ne need for the heavy guns :) On Aug 17, 6:39 pm, cej38 wrote: > My first question would be how do you want to interact with clojure? > Are you going to be using something like Netbeans, or emacs, or > [shudder] vi? The answer really kinda depends on that. > > I really like Netbeans. The Enclojure plug-in works well. Also, all > of these problems with using Macports, and scripts go away. Once you > have Netbeans and Enclojure installed, you download the clojure and > clojure.contrib jars, and point Netbeans at them and you are ready to > go. -- 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: Installing Clojure on OS X
How cake is differ from Dejour? http://github.com/russolsen/dejour Thanks all for help. On Aug 17, 6:41 pm, David Nolen wrote: > On Tue, Aug 17, 2010 at 10:59 AM, HB wrote: > > Hey, > > How to install Clojure on Mac OS X? > > I googled the web, some use MacPorts, others write some shell scripts. > > Is there a -standard- way to install Clojure on OS X (if possible, > > please don't refer me to MacPorts)? > > Thanks all for help and time. > > If you're just getting started and you're on OS X I whole-hearted recommend > Cake. > > sudo gem install cake > > And you're pretty much good to go. You get an excellent autocompleting REPL. > As long as you're not using Cake to design Rake style build tasks, it's > pretty much interchangeable with Leiningen. > > Leiningen is excellent, but Cake benefits from "instant-on" REPLs as well as > providing simpler integration for non-Emacs users (I'm working on a TextMate > bundle). > > David -- 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: Installing Clojure on OS X
On Tue, Aug 17, 2010 at 12:00 PM, HB wrote: > How cake is differ from Dejour? > http://github.com/russolsen/dejour > Thanks all for help. > - "instant-on" REPLs - Excellent tab-completion - Actively developed - My TextMate Clojure bundle relies on it ;) http://github.com/swannodette/textmate-clojure -- 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: Installing Clojure on OS X
On Tue, Aug 17, 2010 at 12:17 PM, David Nolen wrote: > On Tue, Aug 17, 2010 at 12:00 PM, HB wrote: > >> How cake is differ from Dejour? >> http://github.com/russolsen/dejour >> Thanks all for help. >> > > - "instant-on" REPLs > - Excellent tab-completion > - Actively developed > - My TextMate Clojure bundle relies on it ;) > http://github.com/swannodette/textmate-clojure > Heh I mean my fork of the TextMate bundle. Most of the hard work has been done by Stephen Roller, Mark McGranaghan, Aria Haghighi, and others. David -- 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: Nil Coalesce
Here's a pass using reduce, keeping both collections in the return value, conj-ing to one and taking from the other as necessary... (defn nil-coalesce [coll subs] (first (reduce (fn [[a b] x] (if x [(conj a x) b] [(conj a (first b)) (rest b)])) [[] subs] coll))) user> (nil-coalesce [nil 1 2 3 nil nil] [4 5]) [4 1 2 3 5 nil] -- 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: Installing Clojure on OS X
I'm also a relative newbie who works mostly in OS X. If you really just want the core language support and you're going to call java from the command line then you can do the platform-agnostic download from http://clojure.org/downloads and that should work fine. If you want more, like an IDE with some nice language-specific features that takes care of setting the classpath correctly for runs, etc., then I've found that the simplest thing (as a mac user) is Eclipse/Counterclockwise, following the instructions at http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Eclipse_and_Counterclockwisey YMMV, of course, and I only briefly explored the TextMate options. -Lee On Aug 17, 2010, at 10:59 AM, HB wrote: > Hey, > How to install Clojure on Mac OS X? > I googled the web, some use MacPorts, others write some shell scripts. > Is there a -standard- way to install Clojure on OS X (if possible, > please don't refer me to MacPorts)? > Thanks all for help and time. > -- Lee Spector, Professor of Computer Science School of Cognitive Science, Hampshire College 893 West Street, Amherst, MA 01002-3359 lspec...@hampshire.edu, http://hampshire.edu/lspector/ Phone: 413-559-5352, Fax: 413-559-5438 Check out Genetic Programming and Evolvable Machines: http://www.springer.com/10710 - http://gpemjournal.blogspot.com/ -- 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: Installing Clojure on OS X
On Aug 17, 2010, at 10:17 AM, Saul Hazledine wrote: > On Aug 17, 3:59 pm, HB wrote: >> Hey, >> How to install Clojure on Mac OS X? >> I googled the web, some use MacPorts, others write some shell scripts. >> Is there a -standard- way to install Clojure on OS X (if possible, >> please don't refer me to MacPorts)? >> Thanks all for help and time. > > I used a Mac in the past and I understand your frustration with > MacPorts. What's wrong with MacPorts? I've used it to install Clojure (and many other things) on my Mac, without much trouble. -- 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: Nil Coalesce
On Tue, Aug 17, 2010 at 9:30 AM, Rising_Phorce wrote: > Hi All: > > First of all thanks for the replies to my last post the clojure > community is great! > > I've been trying to find a succinct way to do the following. Given > two sequences, product a new sequence which takes items from the first > sequence unless null in which case it will take an item from the > second, until the first sequence is exhausted. If nil is encountered > in the first sequence and the second sequence is exhaused, nil will be > returned: > > e.g. user> (nil-coalesce (nil 1 2 3 nil nil) (4 5)) > (4 1 2 3 5 nil) Clojure golf is the most fun golf! (defn nil-coalesce [a b] (map #(or %1 %2) a (concat b (repeat nil Or if you really want to treat nil and false differently: (defn nil-coalesce [a b] (map #(if (nil? %1) %2 %1) a (concat b (repeat nil --Chouser http://joyofclojure.com/ -- 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: Nil Coalesce
> > Clojure golf is the most fun golf! > > (defn nil-coalesce [a b] > (map #(or %1 %2) a (concat b (repeat nil > > Or if you really want to treat nil and false differently: > > (defn nil-coalesce [a b] > (map #(if (nil? %1) %2 %1) a (concat b (repeat nil > I am not sure to get it. Won't map advance in parrallel in the sequences, jumping over the values in b where there is something in a? -- 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: Nil Coalesce
On Tue, Aug 17, 2010 at 1:38 PM, Nicolas Oury wrote: >> >> Clojure golf is the most fun golf! >> >> (defn nil-coalesce [a b] >> (map #(or %1 %2) a (concat b (repeat nil >> >> Or if you really want to treat nil and false differently: >> >> (defn nil-coalesce [a b] >> (map #(if (nil? %1) %2 %1) a (concat b (repeat nil >> > > > I am not sure to get it. > Won't map advance in parrallel in the sequences, jumping over the > values in b where there is something in a? Oh, indeed. I misunderstood the problem statement. My apologies. --Chouser http://joyofclojure.com/ -- 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: Installing Clojure on OS X
On Aug 17, 6:22 pm, Michael Gardner wrote: > > What's wrong with MacPorts? I've used it to install Clojure (and many other > things) on my Mac, without much trouble. I've never used MacPorts with Clojure and don't use a Mac at all now so things might have improved. However, I had 3 years of trouble using MacPorts as a package system - broken dependencies and inconsistent behaviour across machines being the big problems. My co-workers all had similar experiences so I do understand why some people don't like it. I think the idea behind Homebrew was to address the broken dependency problem by reducing the number of dependencies (so problems propogate less) and to make fixing dependencies more democratic by using git. But my opinion is pretty worthless because I don't use a Mac and I've never used Homebrew :-) Saul -- 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: Clojure Web Programming group?
On Aug 17, 7:15 am, Saul Hazledine wrote: > One idea I had though was to go one step further and start a Clojure > web development group so that other developers of small libraries and > users of them could go to one place for support and discussion. Would > this be uncool or would it be useful? > > Saul I think it would be useful. I don't think it would replace each project's individual list for things like bug reports and feature requests. But it would be nice to have a place for end-users of the various libraries to talk about using them, and talk about integrating them. --Brian -- 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: Clojure Web Programming group?
On Aug 17, 8:21 pm, Brian Carper wrote: > On Aug 17, 7:15 am, Saul Hazledine wrote: > > > One idea I had though was to go one step further and start a Clojure > > web development group so that other developers of small libraries and > > users of them could go to one place for support and discussion. Would > > this be uncool or would it be useful? > > > Saul > > I think it would be useful. I don't think it would replace each > project's individual list for things like bug reports and feature > requests. But it would be nice to have a place for end-users of the > various libraries to talk about using them, and talk about integrating > them. > > --Brian Do you think that it would be a problem is some people (ie me) used such a forum for bug reports and feature requests? Saul -- 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: Clojure Web Programming group?
I'm new to Clojure and fairly new to FP in general. I'm trying to write a web app in Clojure and I would definitely like to see something like that. Tim From: Saul Hazledine To: Clojure Sent: Tue, August 17, 2010 10:15:30 AM Subject: Clojure Web Programming group? Hello, Personally I really like the way web development in Clojure is improving. Rather than huge frameworks there are different libraries that are coming together to form a useful toolset. Even the framework Conjure is lightweight and using general purpose libraries under the hood. One drawback of this library approach though is that it is daunting to beginners. Not only do newcomers have to choose what tools they want to use they have to find a way to fit them together. I've noticed that each library is being supported in their own group/ forum. This is fine for the well used libraries but less mainstream libraries have groups with little traffic. Also, since libraries need to interoperate it would be nice to have a place where library users and library developers are aware of other web development going on. I have developed three small libraries, mostly useful for web work, that could be of interest to other people. However, I don't want to start three different google groups which not only see no traffic but also separate some tools which can be best applied together. Because of this I was going to just have one group that supported all three. One idea I had though was to go one step further and start a Clojure web development group so that other developers of small libraries and users of them could go to one place for support and discussion. Would this be uncool or would it be useful? Saul -- 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: a more general chunk-file
I'm assuming your problem is with memory, and not multithreaded reading. Given that: I also work with files much too big to fit into memory. You could just use java.util.Scanner. That has a useDelimiter method, so you can set the pattern to break on: (defn lazy-read-records [file regex] (let [scanner (java.util.Scanner. file) get-next (fn get-next [] (try (cons (.next scanner) (lazy-seq (get-next))) (catch java.util.NoSuchElementException e (] (.useDelimiter scanner regex) (lazy-seq (get-next The trick here is that the sequence is lazy. It won't read the file until it needs to in order to return the next element. If you don't hold onto the head of the sequence, the front part can be garbage collected while you are working further down. PS If, for some reason, you want the character indices rather than the actual records, replace (.next scanner) with: (do (.next scanner) (.start (.match scanner))) On Aug 16, 2010, at 5:22 PM, cej38 wrote: > Hello, > I work with text files that are, at times, too large to read in all > at one time. In searching for a way to read in only part of the file > I came across > http://meshy.org/2009/12/13/widefinder-2-with-clojure.html > > I am only interested in the chunk-file and read-lines-range functions. > > My problem is that I would like to change chunk-file, so that instead > of looking for the next line break, it would look for some regular > expression (to be given as part of the function call), and would then > report the position of the first character of every instance of that > regular expression. > > After working on this for a couple of days I am raising the white > flag. Is there someone that can help me with this? > > Thanks. > > > > -- > 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: Clojure Web Programming group?
I am playing a bit with shapado (open source stackoverflow clone in ruby, I made an Esperanto QA site with it at demandoj.tk) and maybe it's an idea to create a clojure webdev shapado thus creating a fun to use self-documenting system and using the wikipages etc to provide more information of all separate projects... For project specific stuff I think mailing lists are the best thing since sliced bread. However for newbie questions and documentation it gets messy quite quickly, so I think a QA site for all of the Clojure Webdev stuff might be nice. Weird idea? 2010/8/17 TIM MCIVER : > I'm new to Clojure and fairly new to FP in general. I'm trying to write a > web app in Clojure and I would definitely like to see something like that. > > Tim > > > From: Saul Hazledine > To: Clojure > Sent: Tue, August 17, 2010 10:15:30 AM > Subject: Clojure Web Programming group? > > Hello, > Personally I really like the way web development in Clojure is > improving. Rather than huge frameworks there are different libraries > that are coming together to form a useful toolset. Even the framework > Conjure is lightweight and using general purpose libraries under the > hood. > > One drawback of this library approach though is that it is daunting to > beginners. Not only do newcomers have to choose what tools they want > to use they have to find a way to fit them together. > > I've noticed that each library is being supported in their own group/ > forum. This is fine for the well used libraries but less mainstream > libraries have groups with little traffic. Also, since libraries need > to interoperate it would be nice to have a place where library users > and library developers are aware of other web development going on. > > I have developed three small libraries, mostly useful for web work, > that could be of interest to other people. However, I don't want to > start three different google groups which not only see no traffic but > also separate some tools which can be best applied together. Because > of this I was going to just have one group that supported all three. > > One idea I had though was to go one step further and start a Clojure > web development group so that other developers of small libraries and > users of them could go to one place for support and discussion. Would > this be uncool or would it be useful? > > Saul > > -- > 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 -- Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 Demandoj en aŭ pri Esperanto? Questions about Esperanto? Vragen over Esperanto? Perguntas sobre o Esperanto? - http://demandoj.tk -- 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 more general chunk-file
Er.. This version is better. Uses hasNext instead of catching the exception: (defn lazy-read-records [file regex] (let [scanner (java.util.Scanner. file) get-next (fn get-next [] (if (not (.hasNext scanner)) () (cons (.next scanner) (lazy-seq (get-next)] (.useDelimiter scanner regex) (get-next))) On Aug 17, 2010, at 2:29 PM, Jeff Palmucci wrote: > I'm assuming your problem is with memory, and not multithreaded reading. > Given that: > > I also work with files much too big to fit into memory. > > You could just use java.util.Scanner. That has a useDelimiter method, so you > can set the pattern to break on: > > (defn lazy-read-records [file regex] > (let [scanner (java.util.Scanner. file) >get-next (fn get-next [] > (try > (cons (.next scanner) > (lazy-seq (get-next))) > (catch java.util.NoSuchElementException e (] >(.useDelimiter scanner regex) >(lazy-seq (get-next > > The trick here is that the sequence is lazy. It won't read the file until it > needs to in order to return the next element. > > If you don't hold onto the head of the sequence, the front part can be > garbage collected while you are working further down. > > PS If, for some reason, you want the character indices rather than the actual > records, replace (.next scanner) with: > > (do (.next scanner) >(.start (.match scanner))) > > On Aug 16, 2010, at 5:22 PM, cej38 wrote: > >> Hello, >> I work with text files that are, at times, too large to read in all >> at one time. In searching for a way to read in only part of the file >> I came across >> http://meshy.org/2009/12/13/widefinder-2-with-clojure.html >> >> I am only interested in the chunk-file and read-lines-range functions. >> >> My problem is that I would like to change chunk-file, so that instead >> of looking for the next line break, it would look for some regular >> expression (to be given as part of the function call), and would then >> report the position of the first character of every instance of that >> regular expression. >> >> After working on this for a couple of days I am raising the white >> flag. Is there someone that can help me with this? >> >> Thanks. >> >> >> >> -- >> 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: Nil Coalesce
I posted because clojure *tends* to be so succinct and in this case the solution complexity seems disproportionate to the problem. In my first post I forgot to mention my second attempt... (map #(if (nil? %1) %2 %1) [nil 1 2 3 nil nil] [4 5]) but it got ugly because I needed to extend the replacements to the the same length as the maybe-nil collection... (defn nil-coalesce2 [maybe-nil replacements] (let [cnt-mn (count maybe-nil) cnt-r (count replacements)] (if (= cnt-mn cnt-r) (map #(if (nil? %1) %2 %1) maybe-nil replacements) (map #(if (nil? %1) %2 %1) maybe-nil (concat replacements (repeat (- cnt-mn cnt-r) nil)) -- 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: Nil Coalesce
With the precondition that the first collection is a vector: (use '[clojure.contrib.seq-utils :only [positions]]) (defn nil-coalesce [v subs] (apply assoc v (interleave (positions nil? v) subs))) Justin -- 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: Nil Coalesce
On Tue, Aug 17, 2010 at 3:56 PM, Rising_Phorce wrote: > I posted because clojure *tends* to be so succinct and in this case > the solution complexity seems disproportionate to the problem. In my > first post I forgot to mention my second attempt... > > (map #(if (nil? %1) %2 %1) [nil 1 2 3 nil nil] [4 5]) > > but it got ugly because I needed to extend the replacements to the the > same length as the maybe-nil collection... > > (defn nil-coalesce2 [maybe-nil replacements] > (let [cnt-mn (count maybe-nil) > cnt-r (count replacements)] > (if (= cnt-mn cnt-r) > (map #(if (nil? %1) %2 %1) maybe-nil replacements) > (map #(if (nil? %1) %2 %1) maybe-nil (concat replacements (repeat > (- cnt-mn cnt-r) nil)) Ok, maybe I understand the task now? (defn nil-coalesce [a b] (->> a (reductions (fn [[_ b] a] (if (nil? a) [(first b) (rest b)] [a b])) [0 b]) rest (map first))) This is much like Jeff Valks solution, but lazy. --Chouser http://joyofclojure.com/ -- 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: Nil Coalesce
Hi, Am 17.08.2010 um 21:56 schrieb Rising_Phorce: > I posted because clojure *tends* to be so succinct and in this case > the solution complexity seems disproportionate to the problem. I think the plain lazy-seq version is a pretty straight-forward translation. I don't think, that it is overly complex. In fact it should be easy to understand what happens. I sometimes have trouble in this respect when I see (map first ...) and the likes. Sincerely Meikel -- 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: Nil Coalesce
Another one that works with all collections. Short, but not necessarily the most efficient: (use '[clojure.contrib.seq-utils :only [positions]]) (defn nil-coalesce [coll subs] (map-indexed (zipmap (positions nil? coll) subs) coll)) Justin On Aug 17, 4:10 pm, Justin Kramer wrote: > With the precondition that the first collection is a vector: > > (use '[clojure.contrib.seq-utils :only [positions]]) > > (defn nil-coalesce [v subs] > (apply assoc v (interleave (positions nil? v) subs))) > > Justin -- 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: Nil Coalesce
Neither particularly short nor particularly clever: (defn nil-coalesce [coll subs] (loop [[c & cs :as coll] coll [s & ss :as subs] subs acc []] (if coll (recur cs (if (nil? c) ss subs) (conj acc (if (nil? c) s c))) acc))) On Tue, Aug 17, 2010 at 4:41 PM, Justin Kramer wrote: > Another one that works with all collections. Short, but not > necessarily the most efficient: > > (use '[clojure.contrib.seq-utils :only [positions]]) > > (defn nil-coalesce [coll subs] > (map-indexed (zipmap (positions nil? coll) subs) coll)) > > Justin > > On Aug 17, 4:10 pm, Justin Kramer wrote: >> With the precondition that the first collection is a vector: >> >> (use '[clojure.contrib.seq-utils :only [positions]]) >> >> (defn nil-coalesce [v subs] >> (apply assoc v (interleave (positions nil? v) subs))) >> >> Justin > > -- > 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: Clojure Web Programming group?
I think there's a lot of questions that a Clojure programmer faces when doing web programming, not only regarding how the libraries work, but also regarding how to design a larger-than-trivial web applications. A mail list would be a very good way to be able to ask for advice or to be inspired by solutions other people have come up with. I think there is a lack of articles and blog posts on the web where people write about the experiences they had during the development of their web applications. I always get the feeling that what I am struggling with, some else has already struggled with too and maybe even solved. During the time I've done web development, I've been searching for something like this. // Rasmus -- 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: Nil Coalesce
(defn fill [coll subs] (lazy-seq (when-let [[x & nx :as xs] (seq coll)] (if-let [[y & ny :as ys] (seq subs)] (if (nil? x) (cons y (fill nx ny)) (cons x (fill nx ys))) xs On Aug 17, 6:30 am, Rising_Phorce wrote: > Hi All: > > First of all thanks for the replies to my last post the clojure > community is great! > > I've been trying to find a succinct way to do the following. Given > two sequences, product a new sequence which takes items from the first > sequence unless null in which case it will take an item from the > second, until the first sequence is exhausted. If nil is encountered > in the first sequence and the second sequence is exhaused, nil will be > returned: > > e.g. user> (nil-coalesce (nil 1 2 3 nil nil) (4 5)) > (4 1 2 3 5 nil) > > I ended up with a scheme like natural recursion. I see two > drawbacks. The result (presumably empty) must be passed in and the > recursion will stack overflow for large sequences. I guess trampoline > would fix this, but that seems a bit of a dirty trick and workaround > until Java 7 gives us proper tail calls. Anyway I looked at partition > and interleave but without a predicate, I don't see how to make either > of these work. Anyone have a more elegant solution? > > (defn nil-coalesce [result maybe-nil replacements] > (if (empty? maybe-nil) > (if (empty? replacements) > result > nil) > (let [x (first maybe-nil) xs (rest maybe-nil)] > (if (nil? x) > (recur (conj result (first replacements)) xs (rest > replacements)) > (recur (conj result x) xs replacements) -- 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: Nil Coalesce
Oh, and, duh. Both lists are traversed at each iteration as Nicolas stated. On Aug 17, 3:56 pm, Rising_Phorce wrote: > I posted because clojure *tends* to be so succinct and in this case > the solution complexity seems disproportionate to the problem. In my > first post I forgot to mention my second attempt... > > (map #(if (nil? %1) %2 %1) [nil 1 2 3 nil nil] [4 5]) > > but it got ugly because I needed to extend the replacements to the the > same length as the maybe-nil collection... > > (defn nil-coalesce2 [maybe-nil replacements] > (let [cnt-mn (count maybe-nil) > cnt-r (count replacements)] > (if (= cnt-mn cnt-r) > (map #(if (nil? %1) %2 %1) maybe-nil replacements) > (map #(if (nil? %1) %2 %1) maybe-nil (concat replacements (repeat > (- cnt-mn cnt-r) nil)) -- 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: Emacs auto-complete plugin for slime users
This is great, thanks! Fuzzy completion (ac-source-slime-fuzzy) isn't working for me. It complains that slime-fuzzy-comp On Sat, Aug 14, 2010 at 5:19 AM, Steve Purcell wrote: > Hi all, > > A while ago I hooked Slime's completion and documentation features into the > popular Emacs auto-completion framework "auto-complete" ( > http://www.emacswiki.org/emacs/AutoComplete). > > Since it may be of interest to others, I've released the completion plugin > on github: http://github.com/purcell/ac-slime > > Here's a screenshot of the plugin in action in a clojure-mode buffer, > showing the (very handy) pop-up documentation: > > > > > > > -Steve > -- > 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: ANN: Emacs auto-complete plugin for slime users
Sorry my message got truncated. Let's try again: Fuzzy completion (ac-source-slime-fuzzy) isn't working for me. It complains that the function slime-fuzzy-completions is not defined. I'm using slime.el version 2010404, which does not define that function, although it does define slime-simple-completions. Not sure if there's a newer version of slime.el out there but I did install fresh about a week or two ago. Not to worry; I'm very happy with ac-source-slime-simple. Steve On Tue, Aug 17, 2010 at 3:17 PM, Steve Molitor wrote: > This is great, thanks! > > Fuzzy completion (ac-source-slime-fuzzy) isn't working for me. It > complains that slime-fuzzy-comp > > On Sat, Aug 14, 2010 at 5:19 AM, Steve Purcell wrote: > >> Hi all, >> >> A while ago I hooked Slime's completion and documentation features into >> the popular Emacs auto-completion framework "auto-complete" ( >> http://www.emacswiki.org/emacs/AutoComplete). >> >> Since it may be of interest to others, I've released the completion plugin >> on github: http://github.com/purcell/ac-slime >> >> Here's a screenshot of the plugin in action in a clojure-mode buffer, >> showing the (very handy) pop-up documentation: >> >> >> >> >> >> >> -Steve >> -- >> 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: Nil Coalesce
Devious! The OP wanted to handle underflow of the subs collection though, so you need a tweak: (apply assoc v (interleave (positions nil? v) (concat subs (repeat nil On Aug 17, 1:10 pm, Justin Kramer wrote: > With the precondition that the first collection is a vector: > > (use '[clojure.contrib.seq-utils :only [positions]]) > > (defn nil-coalesce [v subs] > (apply assoc v (interleave (positions nil? v) subs))) > > Justin -- 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: Nil Coalesce
If solving a more general problem first counts as elegant, then here is a solution: (defn map-replace "Return coll but replace every element for which pred returns true with (f element replacement-element) as long as there are replacement elements in replacements" [pred f coll replacements] (lazy-seq (if (seq coll) (let [[x & xs] coll [y & ys] replacements] (if (pred x) (cons (f x y) (map-replace pred f xs ys)) (cons x (map-replace pred f xs replacements))) (defn nil-coalesce "Replace all occurrences of nil in coll with replacement items in replacements" [coll replacements] (map-replacements nil? (fn [x y] y) coll replacements)) -- 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: Installing Clojure on OS X
I usually do: 1) lein new your-project-name 2) cd your-project-name, add :dev-dependencies [[swank-clojure "1.3.0- SNAPSHOT"]] to your project.clj, and run lein deps 3) run lein swank 4) Connect from emacs with M-x slime-connect and accept the default options it gives you. I haven't had any trouble with macports. Also, emacs will offer to install clojure for you when it's first set up for clojure. For emacs I use emacs-app from macports. I have the following in ~/.emacs.d/site-lisp/ (you probably wouldn't want all of this): ac-slime cedet cmuscheme ecb ess-5.11 paredit quack swank-clojure cedet-1.0pre7 php-mode-1.5.0 sbt slime-2010-07-27 auto-complete-1.3 clojure-mode color-theme-6.6.0 elib-1.0 jdee-2.4.0.1 pure-mode scala smart-tab My .emacs is: ;; Easier to load-path (defun add-subdirs-to-load-path (dir) (let ((default-directory (concat dir "/"))) (normal-top-level-add-subdirs-to-load-path))) (add-to-list 'load-path "~/.emacs.d/site-lisp/") (add-subdirs-to-load-path "~/.emacs.d/site-lisp/") ;; LOOK OF EMACS ; "y or n" instead of "yes or no" (fset 'yes-or-no-p 'y-or-n-p) ; Display line and column numbers (setq line-number-mode t) (setq column-number-mode t) (global-set-key "\C-c\C-w" 'backward-kill-word) (show-paren-mode 1) ;; Color theme (require 'color-theme) (eval-after-load "color-theme" '(progn (color-theme-initialize) (color-theme-euphoria))) (set-cursor-color "yellow") (setq-default cursor-type '(bar . 2)) (blink-cursor-mode 1) (global-hl-line-mode 1) ; highlight the current line (set-face-background 'hl-line "grey10") (set-default-font "-apple-Andale_Mono-medium-normal-normal-*-12-*-*-*- m-0-iso10646-1") (modify-frame-parameters nil '((wait-for-wm . nil))) ;; gui stuff (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) (if (fboundp 'tool-bar-mode) (tool-bar-mode 1)) (if (fboundp 'menu-bar-mode) (menu-bar-mode 1)) ;; Line numbers, indents etc. (setq standard-indent 2) ; Indent size 2 (global-linum-mode -1) ; Line numbers on side ;; Useful commands (add-hook 'text-mode-hook 'turn-on-auto-fill) ;; History (savehist-mode 1) (desktop-save-mode 1) (setq history-length 250) (add-to-list 'desktop-globals-to-save 'file-name-history) ;; Smart Tab (require 'smart-tab) ;; make sure smart-tab.el is reachable in your load-path first (global-smart-tab-mode 1) ;; switch on smart-tab everywhere (setq smart-tab-completion-functions-alist '((emacs-lisp-mode . lisp-complete-symbol) (text-mode . dabbrev-completion) ;; this is the "default" emacs expansion function (clojure-mode . slime-complete-symbol))) ;; see update below ;; Auto-complete (require 'auto-complete-config) (add-to-list 'ac-dictionary-directories "~/.emacs.d/site-lisp/auto- complete/ac-dict") (ac-config-default) ;; For this see ;; http://github.com/purcell/ac-slime ;; http://groups.google.com/group/clojure/browse_thread/thread/09dde36a2ab572df/1ca36e456d31aa58#1ca36e456d31aa58 (require 'ac-slime) (add-hook 'slime-mode-hook 'set-up-slime-ac) (add-hook 'slime-repl-mode-hook 'set-up-slime-ac) (setq ac-sources (append '(ac-source-slime-simple) ac-sources)) ;; CEDET ;(load-file "/Users/daviddreisigmeyer/.emacs.d/site-lisp/cedet/common/ cedet.el") ;(global-ede-mode t) ;; ECB (require 'ecb) (setq ecb-tip-of-the-day nil) (setq ecb-layout-name "my-right-dsh") ; Make it easier to start and stop ecb ; The small window size with a Mac messes up the format (defun ea () (interactive) (ecb-activate)) (defun ed () (interactive) (ecb-deactivate)) ;; ESS (require 'ess-site) ;; SLIME (setq slime-lisp-implementations '((sbcl ("/usr/local/bin/sbcl" ; '((ccl ("/usr/local/bin/ccl64" (require 'slime) (slime-setup '(slime-fancy slime-banner slime-asdf slime-sbcl-exts)) (setq slime-use-autodoc-mode nil) ; So slime-fancy will work with clojure (global-set-key "\C-cs" 'slime-selector) ; C-c s r takes us to the slime repl ;; CLOJURE (autoload 'clojure-mode "clojure-mode" "A major mode for Clojure" t) (add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode)) (require 'swank-clojure) (setq slime-lisp-implementations (append slime-lisp-implementations `((clojure ,(swank-clojure-cmd) :init swank-clojure- init ;; For Rincanter (setenv "R_HOME" "/Library/Frameworks/R.framework/Resources") ;; For JAVA (require 'jde) ;; ;; PAREDIT ;; ;; http://coding.derkeiler.com/Archive/Lisp/comp.lang.lisp/2007-07/msg01505.html ;; ;; ;; (autoload 'paredit-mode "paredit" "Minor mode for pseudo-structurally editing Lisp code." t) (require 'paredit) (add-hook 'emacs-lisp-mode-hook (lambda () (paredit-mode +1))) (add-hook 'lisp-mode-hook (lambda () (paredit-mode +1))) (add-hook 'lisp-interaction-mode-hook (lambda () (paredit-mode +1))) (add-hook 'slime-repl-mode-hook (lambda () (paredit-mode +1))) (add-hook 'clojure-mode-hook (lambda () (paredit-mode +1))) (add-hook 'inferior-lisp-mode-hook (lambda () (paredit-mode +1))) ;; Stop SLIME's R
Re: Nil Coalesce
On Aug 17, 4:42 pm, Alan wrote: > Devious! The OP wanted to handle underflow of the subs collection > though, so you need a tweak: > (apply assoc v (interleave (positions nil? v) > (concat subs (repeat nil interleave stops once either collection is exhausted. In your modified version, nils replace nils when there are fewer substitutions than nil positions, which is unnecessary. Unless I'm missing something...which is entirely possible. It does fail when subs is empty, though. So: (defn nil-coalesce [v subs] (if (empty? subs) v (apply assoc v (interleave (positions nil? v) subs Off the golf course, I would probably use something like Meikel's or ataggart's. I agree with Meikel that the lazy-seq approach is straight- forward to understand, assuming you're familiar with lazy-seq idioms. Justin -- 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
Elisp for highlighting java method names in slime inspector
It's always bothered me that when inspecting a class in Slime the method names are highlighted in the same color as public static int etc. I think it makes it hard to see what methods are available. I wrote this elisp that highlights the method names in a different color: (add-hook 'slime-inspector-mode-hook (lambda () (font-lock-add-keywords nil '(("\\(\\w+\\)(" 1 font-lock-function-name-face) Unfortunately it causes the other highlighting to stop working. If you know why or have a better regex feel free to respond. Scott -- 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: Installing Clojure on OS X
On Tue, Aug 17, 2010 at 07:59, HB wrote: > Hey, > How to install Clojure on Mac OS X? > I wrote this pre 1.2: https://docs.google.com/Doc?docid=0AW2Ojyy-IGoHZGR0c256dmZfNTRjenBoYnBjaA&hl=en There are likely a few changes needed but a cursory glance and it mostly looks right. In summary - use emacsformacosx.com and the elpa install and run your projects through lein swank and you're good to go. -- 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: Nil Coalesce
On 18 August 2010 04:44, Justin Kramer wrote: > On Aug 17, 4:42 pm, Alan wrote: >> Devious! The OP wanted to handle underflow of the subs collection >> though, so you need a tweak: >> (apply assoc v (interleave (positions nil? v) >> (concat subs (repeat nil > > interleave stops once either collection is exhausted. In your modified > version, nils replace nils when there are fewer substitutions than nil > positions, which is unnecessary. Unless I'm missing something...which > is entirely possible. "nils replace nils when there are fewer substitutions than nil positions" was one of the requirements. >From the first post: > If nil is encountered in the first sequence and the second sequence is > exhaused, nil will be returned: > > e.g. user> (nil-coalesce (nil 1 2 3 nil nil) (4 5)) > (4 1 2 3 5 nil) -- Michael Wood -- 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