Re: Question about Responsiveness of Garbage Collection
In general, accusing garbage collection of being culprit for sluggish GUI performance is plain wrong. Swing GUIs can be quite snappy when done right - but surely there are lots of not-so-right done apps out there. Also, the amount of GC required depends a lot on what you're doing, and how. Typical menus, buttons and texts are quite light. But if you're streaming a full-screen video and not re-using any buffers, then there's definitely massive GC going on. VisualVM (https://visualvm.dev.java.net/) is a convenient tool to check what's going on in a particular application, performance-wise. Best Regards, Joonas -- 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: Case-insensitive map?
> There's a library in clojure.contrib which allows to create your own > getters / setters for maps : > > http://richhickey.github.com/clojure-contrib/fnmap-api.html This is actually a very cool approach and it fits my ideas quite well. The only problem I have with it is that it constructs a whole new map from keyvals. That sounds a bit expensive. Maybe it is possible do something similar which just wraps over an existing map. I see if I can come up with something like that. I understand that this doesn't guarantee my the consistency within the map as I get it from having all insertions done through the same setter. But in a case where one just wants some transformation relying on the getter, that doesn't matter. Anyway, thanks for the pointer to this lib! -- Florian Ebeling florian.ebel...@gmail.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
Promise/Deliver use cases
Hello, I am trying to understand the use-cases of the new promise/deliver feature in Clojure. I have tried using them, and they seem to be pretty straight-forward to use, but unfortunately I haven't been able to understand its use-cases. It would be great if someone pointed out some example usage of promise/deliver. Regards, BG -- Baishampayan Ghose -- 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: Promise/Deliver use cases
In a nutshell, those are the building blocks for the "dataflow programming paradigm". It's an easy way to make a computation done in thread A (and using a pre-declared promise) block until thread B has delivered the promise (given it its value). The book CTM covers dataflow programming : http://www.info.ucl.ac.be/~pvr/book.html Now, to be honest, i still haven't read the related parts of the book, and I'm unable to give more concrete examples yet :-) 2010/1/21 Baishampayan Ghose : > Hello, > > I am trying to understand the use-cases of the new promise/deliver > feature in Clojure. I have tried using them, and they seem to be > pretty straight-forward to use, but unfortunately I haven't been able > to understand its use-cases. > > It would be great if someone pointed out some example usage of > promise/deliver. > > Regards, > BG > > -- > Baishampayan Ghose > > -- > 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: Autodoc for the masses
On Wed, Jan 20, 2010 at 12:51 PM, Tom Faulhaber wrote: > Now your project can have the same documentation as Clojure, clojure- > contrib, and Incanter! > > The standalone autodoc tool is now available. It can be run from the > command line and it integrates with Leiningen and ant. (Maven still to > come - let me know if you want to help.) > > Autodoc builds full, styled HTML documentation from your doc-strings > and other metadata you supply. It includes a project overview page, > separate pages for each namespace, and an overall index page. > > It builds pages suitable for use with github pages so you can easily > publish documentation and can include links to source code if you > publish source. > > Documentation on how to get and use Autodoc is here: > http://tomfaulhaber.github.com/autodoc/ (apologies for the fact that > the doc is not yet pretty!). > > I hope that Autodoc helps you increase the quality of documentation > for your projects. > > Enjoy, > > Tom Faulhaber > That's awesome - thanks Tom! Rich -- 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
function to perform operations on adjacent values
looking for something very similar to reduce, but sequentially operate on adjacent values for example if (defn reduce-n [f col n]) (reduce-n + (range 7) 2) => (3 7 11) ie 1+2, 3+4, 5+6 ideas? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Multimethod attribute maps
Hi, Am 20.01.2010 um 14:02 schrieb Jacek Generowicz: > In Clojure 1.1.0, the documentation states: > > clojure.core/defmulti > ([name docstring? attr-map? dispatch-fn & options]) > Macro > Creates a new multimethod with the associated dispatch function. > The docstring and attribute-map are optional. > > Options are key-value pairs and may be one of: >:defaultthe default dispatch value, defaults to :default >:hierarchy the isa? hierarchy to use for dispatching >defaults to the global hierarchy > > What is the purpose of the attribute map (and, perhaps more > importantly, where could I have found an explanation in the > documentation) ? You can eg. add information about argument lists or other meta data. (defmulti foo "foo does bar with baz and frob." {:arglists '([baz] [baz frob])} (fn [& args] (vec (map type args Try to define one multimethod with such an arglists definition and one without. Then invoke doc on both and see the difference. 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
Eval troubles
I'm a clojure newbie, but bear with me; I'm trying to save an expression that contains a function I've defined earlier, and then selectively evaluate it later. (The idea is that I will swap out the function later in the code). Something like (defn y [a b] (+ a b)) (def x '(y 1 2)) (defn -main [] (println (eval x))) which yields "Unable to resolve symbol: y in this context (NO_SOURCE_FILE:7)" etc. If I do it via the REPL, it works fine, as does using built-in functions as code, eg (def x '(+ 1 2)) (defn -main [] (println (eval x))) yields 3 as expected. What am I missing? -- 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: Multimethod attribute maps
On Jan 20, 1:02 pm, Jacek Generowicz wrote: > clojure.core/defmulti > ([name docstring? attr-map? dispatch-fn & options]) > What is the purpose of the attribute map [...] ? Answering my own question: It's not specific to multimethods. It's the metadata, and most def- forms have such an optional attr-map parameter. -- 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: Multimethod attribute maps
The attr-map adds key-value pairs to the metadata for the function symbol. The doc for 'defn' makes this clearer. On Jan 20, 8:02 am, Jacek Generowicz wrote: > In Clojure 1.1.0, the documentation states: > > clojure.core/defmulti > ([name docstring? attr-map? dispatch-fn & options]) > Macro > Creates a new multimethod with the associated dispatch function. > The docstring and attribute-map are optional. > > Options are key-value pairs and may be one of: > :default the default dispatch value, defaults to :default > :hierarchy the isa? hierarchy to use for dispatching > defaults to the global hierarchy > > What is the purpose of the attribute map (and, perhaps more > importantly, where could I have found an explanation in the > documentation) ? > > Thank you. -- 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: function to perform operations on adjacent values
On 20.01.2010, at 20:03, Scott wrote: looking for something very similar to reduce, but sequentially operate on adjacent values for example if (defn reduce-n [f col n]) (reduce-n + (range 7) 2) => (3 7 11) ie 1+2, 3+4, 5+6 ideas? That's (range 1 7) instead of (range 7), right? In that case, one solution is (map (partial apply +) (partition 2 (range 1 7))) Konrad. -- 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: function to perform operations on adjacent values
partition creates a sequence of sequences of adjacent values user=> (partition 2 (range 1 7)) ((1 2) (3 4) (5 6)) and you can apply reduce to each of the sequences using map user=> (map #(reduce + %) (partition 2 (range 1 7))) (3 7 11) or user=> (map (partial reduce + ) (partition 2 (range 1 7))) (3 7 11) Chris On Jan 20, 7:03 pm, Scott wrote: > looking for something very similar to reduce, but sequentially operate > on adjacent values > > for example > > if > (defn reduce-n [f col n]) > > (reduce-n + (range 7) 2) > => (3 7 11) > > ie > 1+2, 3+4, 5+6 > > ideas? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Eval troubles
Hi, > (defn y [a b] (+ a b)) > (def x '(y 1 2)) > > (defn -main [] > (println (eval x))) > > which yields > > "Unable to resolve symbol: y in this context (NO_SOURCE_FILE:7)" > etc. > What am I missing? The problem is namespace inside the function used by gen-class (and it this case your -main function) is set to 'clojure.core and not to your current namespace. Move your code to some other function and call it from your -main, I think it should work then. -- Krešimir Šojat -- 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: Eval troubles
Hi, On Jan 20, 11:10 pm, Bryce wrote: > What am I missing? Try ` instead of '. eval evaluates the expression with a different ns. Since y is not properly quoted it is not found. ` will resolve y to its qualified name and everything will work out. Standard Disclaimer: this is only one subtle gotcha with eval. In 99% of all cases it is worth the trouble to find a solution without eval. 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: function to perform operations on adjacent values
Hi, On Jan 20, 8:03 pm, Scott wrote: > (reduce-n + (range 7) 2) > => (3 7 11) user=> (map #(reduce + %1) (partition 2 (range 1 7))) (3 7 11) 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: Case-insensitive map?
Hi, On Jan 21, 11:01 am, "C. Florian Ebeling" wrote: > This is actually a very cool approach and it fits my ideas quite well. > The only problem I have with it is that it constructs a whole new map > from keyvals. Maybe it is possible do something similar which just wraps > over an existing map. I think you misread the source of fnmap. Of course it creates a new map in the beginning just as hash-map does. Then assoc/dissoc/etc. just delegates to the underlying map with the appropriate fiddling with the setter/getter. If you already have a map you can do something like: (require '[clojure.contrib.fnmap.PersistentMap :as fnmap]) (defn to-fnmap [the-map setter getter] (clojure.contrib.fnmap.PersistentFnMap. (assoc the-map ::fnmap/ setter setter ::fnamp/getter getter))) > That sounds a bit expensive. Did you try? "sounds" is not the best advisor. 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: update-in! (?)
I don't think zipper would help in this case On Jan 21, 12:40 am, brianh wrote: > Any chance you could rethink your approach & use a zipper? > > On Jan 20, 9:32 am, Gabi wrote: > > > I posted a question on SO about it. Interesting > > discussion:http://stackoverflow.com/questions/2102606/algorithm-to-implement-non... > > > On Jan 20, 5:39 pm, Christophe Grand wrote: > > > > I concur: a map (or a sorted map if you need to emulate access to a > > > subtree) can be an option. > > > > [[1 2] [3 4]] is represented by {[0 0] 1, [0 1] 2, [1 0] 3, [1 1] 4} > > > > On Wed, Jan 20, 2010 at 4:24 PM, Sean Devlin > > > wrote: > > > > How about a sorted set w/ a custom comparator? Of course, this rules > > > > out transients, but maybe the flatness will make up for it? > > > > > On Jan 20, 10:15 am, Gabi wrote: > > > >> I need to add/delete much more frequently than just updating > > > >> actually. > > > > >> On Jan 20, 4:59 pm, Sean Devlin wrote: > > > > >> > Gabi, > > > >> > A similar technique is used with sparse matrices. You usually have > > > >> > severals arrays, one for the non-zero elements, and another one for > > > >> > indexing the column and a third for indexing the rows. > > > > >> >http://pasadena.wr.usgs.gov/office/baagaard/research/papers/thesis/fi... > > > > >> > This should be fast as long as you're only updating. If you're > > > >> > inserting/deleting, you might be able to get away with using a > > > >> > collection of 1D trees. > > > > >> > Sean > > > > >> > On Jan 20, 9:18 am, Gabi wrote: > > > > >> > > These vectors represent trees which need to updated very > > > >> > > frequently. > > > >> > > So If there was an efficient way to use transients to represent > > > >> > > transient trees the whole process would be much more efficient (so > > > >> > > each update to a tree would be done in place instead of creating > > > >> > > new > > > >> > > one.) As discussed above, naive usage of transients won't help. > > > >> > > Another approach would be implement in Java, but I wish there would > > > >> > > some way to achieve this directly from Clojure. > > > >> > > Now that I think about it, maybe the solution is to represent the > > > >> > > tree > > > >> > > as one dimensional vector instead of nested one (any good clojure > > > >> > > algorithm for this ? Representing and traversing non binary trees > > > >> > > as > > > >> > > one dimensional vector?) > > > > >> > > Jan 20, 12:53 pm, Christophe Grand wrote: > > > > >> > > > Hi Gabi! > > > > >> > > > Can you tell us more about your problem, what do those deeply > > > >> > > > nested > > > >> > > > vectors represent and how are you going to update them? (are all > > > >> > > > updates batched in one part of your program?) > > > > >> > > > With transients current implementation you can't write an > > > >> > > > efficient update-in! > > > > >> > > > Christophe > > > > >> > > > On Wed, Jan 20, 2010 at 9:15 AM, Gabi > > > >> > > > wrote: > > > >> > > > > Guys, I really need your expertise here. > > > >> > > > > I have lots of deeply nested vectors, which i need to > > > >> > > > > manipulate > > > >> > > > > frequently (thousands of times) > > > >> > > > > What is the most effective way to do this ? > > > > >> > > > > On Jan 17, 4:27 pm, Gabi wrote: > > > >> > > > >> Right. I thought that transient performing deep > > > >> > > > >> 'transientivity'. > > > >> > > > >> Here is a fixed version. It takes a regular coll converts > > > >> > > > >> whatever it > > > >> > > > >> can to transient and update the stuff. > > > >> > > > >> The problem is that doing persistent!(assoc!(transient m)) on > > > >> > > > >> each > > > >> > > > >> level probably misses the whole point of performance. > > > >> > > > >> So while it work, it probably slower than the regular > > > >> > > > >> update-in. > > > >> > > > >> I need a better solution. > > > > >> > > > >> (defn update-in!! > > > >> > > > >> "modified version of core/update-in that works on, and > > > >> > > > >> return > > > >> > > > >> transiants" > > > >> > > > >> ([m [k & ks] f & args] > > > >> > > > >> (if ks > > > >> > > > >> (persistent!(assoc! (transient m) k (apply update-in!! > > > >> > > > >> (get m k) > > > >> > > > >> ks f args))) > > > >> > > > >> (persistent!(assoc! (transient m) k (apply f (get m k) > > > >> > > > >> args)) > > > > >> > > > >> On Jan 17, 3:57 pm, Chouser wrote: > > > > >> > > > >> > On Sun, Jan 17, 2010 at 8:25 AM, Gabi > > > >> > > > >> > wrote: > > > > >> > > > >> > >> user=> (persistent!(update-in!(transient v) [0] reverse)) > > > > >> > > > >> > > Forgot to mention that v in the example is defined to > > > >> > > > >> > > [[1 2] [3 4]] > > > > >> > > > >> > So you've got a transient vector of persistent vectors of > > > >> > > > >> > numbers. The problem is your update-in! then calls assoc! > > > >> > > > >> > on > > > >> > > > >> > each level, but of course assoc! on the inner persistent > > > >> > > > >> > vector > > > >>
Re: Case-insensitive map?
> I think you misread the source of fnmap. Of course it creates a new > map in the beginning just as hash-map does. Then assoc/dissoc/etc. > just delegates to the underlying map with the appropriate fiddling > with the setter/getter. > > If you already have a map you can do something like: > > (require '[clojure.contrib.fnmap.PersistentMap :as fnmap]) > > (defn to-fnmap > [the-map setter getter] > (clojure.contrib.fnmap.PersistentFnMap. (assoc the-map ::fnmap/ > setter setter ::fnamp/getter getter))) I didn't read the code as thoroughly as you did. Thanks for pointing out this approach. It would make a nice addition to the exposed API. -- Florian Ebeling florian.ebel...@gmail.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
Using docs effectively (Ratio)
Clojure has a Ratio type; presumably there should be an easy way to find the numerator and denominator of a Ratio object. I didn't have much luck on clojure.org or with find-doc, but (show 1/2) taught me that there are numerator and denominator methods on Ratio's underlying Java implementation, so I can now do: (.numerator 1/2) ; => 1 (.denominator 1/2) ; => 2 Is there a more direct way? (Not that this is bad! But you can't use .numerator as a first-order function (though #(.numerator %) is still pretty damn good).) In general, do you have any hints on how to go about looking for useful Clojure functions which work with certain Clojure types ? Thank you. -- 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: Autodoc for the masses
Tom, Thanks for providing this great tool. I was able to install it last night, it just plain works. Keep hacking! Sean On Jan 20, 12:51 pm, Tom Faulhaber wrote: > Now your project can have the same documentation as Clojure, clojure- > contrib, and Incanter! > > The standalone autodoc tool is now available. It can be run from the > command line and it integrates with Leiningen and ant. (Maven still to > come - let me know if you want to help.) > > Autodoc builds full, styled HTML documentation from your doc-strings > and other metadata you supply. It includes a project overview page, > separate pages for each namespace, and an overall index page. > > It builds pages suitable for use with github pages so you can easily > publish documentation and can include links to source code if you > publish source. > > Documentation on how to get and use Autodoc is > here:http://tomfaulhaber.github.com/autodoc/(apologies for the fact that > the doc is not yet pretty!). > > I hope that Autodoc helps you increase the quality of documentation > for your projects. > > Enjoy, > > Tom Faulhaber -- 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 about Responsiveness of Garbage Collection
On Jan 21, 3:20 am, Joonas Pulakka wrote: > In general, accusing garbage collection of being culprit for sluggish > GUI performance is plain wrong. Swing GUIs can be quite snappy when > done right - but surely there are lots of not-so-right done apps out > there. >From my limited experience with Swing, coding techniques can make a big difference. There are a lot of poorly-written Swing apps out there. Get a good reference book to make sure you're doing it right. -SS -- 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: Promise/Deliver use cases
Promises (and dataflow programming in general) are really useful with interacting with physical devices, especially robots. Suppose you have a 200 ton press, with a safety sensor. You have the following code: (def is-it-safe? (promise)) (defn activate-press [] (if @is-it-safe? (go!))) (defn poll-sensor [] (loop [] (if (= (read-sensor) :safe) (deliver is-it-safe :safe) (do (Thread/sleep 50) recur Now, the poll-sensor fn is usually running in a daemon thread somewhere else. The call to activate-press will happen at a seemingly random time, at least as far as poll-sensor is concerned. The promise forces the press to wait unit it's safe to activate. There are all sort of other conditions where this makes sense when dealing with mechanics. This is just one. HTH, Sean On Jan 21, 6:40 am, Laurent PETIT wrote: > In a nutshell, those are the building blocks for the "dataflow > programming paradigm". > > It's an easy way to make a computation done in thread A (and using a > pre-declared promise) block until thread B has delivered the promise > (given it its value). > > The book CTM covers dataflow programming > :http://www.info.ucl.ac.be/~pvr/book.html > > Now, to be honest, i still haven't read the related parts of the book, > and I'm unable to give more concrete examples yet :-) > > 2010/1/21 Baishampayan Ghose : > > > Hello, > > > I am trying to understand the use-cases of the new promise/deliver > > feature in Clojure. I have tried using them, and they seem to be > > pretty straight-forward to use, but unfortunately I haven't been able > > to understand its use-cases. > > > It would be great if someone pointed out some example usage of > > promise/deliver. > > > Regards, > > BG > > > -- > > Baishampayan Ghose > > > -- > > 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
Suggest slime-redirect-inferior-output be default for Swank clojure
Hello, As detailed in Bradford Cross' blog, (http:// measuringmeasures.blogspot.com/2010/01/agony-of-clojurehadoop-logging- and-how.html) the rebinding of *out* done in the swank/slime repl can be very confusing to folk who don't already know slime. This is because so many java libraries output to stdout. And within Clojure it is very easy to have output happening on a different threads where *out* is still bound stdout which all goes to the *inferior-lisp* buffer (usually hidden) not the repl. The helpful advice given in comments on the blog post is to use "slime- redirect-inferior-output". With that all stdout ends up in the repl buffer. A direct result of all the effort to make it very easy to get up and running with emacs/slime/swank/clojure is that many folk inexperienced with slime will be encountering it for the first time using clojure (like me for instance). Might I suggest that "slime-redirect-inferior-output" be the default for swank-clojure-project? That is much less surprising to newbies who don't yet know about *out*, thread bindings, and swank/slime's rebinding of *out* in the clojure repl. Thanks, Alex Stoddard -- 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
ANN: leiningen war plugin
There is a plugin for leiningen that creates war files for use with servlet containers: http://github.com/alienscience/leiningen-war/ http://clojars.org/uk.org.alienscience/leiningen-war To use it include the following dev-dependency in project.clj :dev-dependencies [[uk.org.alienscience/leiningen-war "0.0.1"]] It meets my needs so far but I'm happy to changes -- however radical they are. 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: function to perform operations on adjacent values
Thanks! On Jan 21, 7:07 am, Meikel Brandmeyer wrote: > Hi, > > On Jan 20, 8:03 pm, Scott wrote: > > > (reduce-n + (range 7) 2) > > => (3 7 11) > > user=> (map #(reduce + %1) (partition 2 (range 1 7))) > (3 7 11) > > 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: Suggest slime-redirect-inferior-output be default for Swank clojure
Seconded. I found this very confusing when I first started with Clojure. 2010/1/21 Alex Stoddard > Hello, > > As detailed in Bradford Cross' blog, (http:// > measuringmeasures.blogspot.com/2010/01/agony-of-clojurehadoop-logging- > and-how.html) the rebinding of *out* done in the swank/slime repl can > be very confusing to folk who don't already know slime. This is > because so many java libraries output to stdout. And within Clojure it > is very easy to have output happening on a different threads where > *out* is still bound stdout which all goes to the *inferior-lisp* > buffer (usually hidden) not the repl. > > The helpful advice given in comments on the blog post is to use "slime- > redirect-inferior-output". With that all stdout ends up in the repl > buffer. > > A direct result of all the effort to make it very easy to get up and > running with emacs/slime/swank/clojure is that many folk inexperienced > with slime will be encountering it for the first time using clojure > (like me for instance). > > Might I suggest that "slime-redirect-inferior-output" be the default > for swank-clojure-project? That is much less surprising to newbies > who don't yet know about *out*, thread bindings, and swank/slime's > rebinding of *out* in the clojure repl. > > Thanks, > Alex Stoddard > > -- > 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
Agents of Swing ported to Jwt
Hi, After reading Stuart Sierra's post titled "Agents of Swing" [1] I couldn't wait to try and port it to Jwt [2]. I finally had the time and documented it in a blog post at http://www.nsa.be/index.php/eng/Blog/From-Swing-to-Jwt I thought this could be of interest to some people here, expecially those looking for a web app framework. Cheers Raph [1] http://stuartsierra.com/2010/01/08/agents-of-swing [2] http://www.webtoolkit.eu/jwt -- 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: Autodoc for the masses
Just a quick note about getting setup with Leiningen. The documentation you posted says to use [autodoc "0.7.0-SNAPSHOT"] in the dev dependencies, but that is not a valid package on clojars. Using [autodoc "0.7.0"] instead works fine though. No downloading of jars necessary. Just add that, run "lein deps", and then autodoc will be an available lein command. Thanks! -Jeff On Jan 20, 6:51 pm, Tom Faulhaber wrote: > Now your project can have the same documentation as Clojure, clojure- > contrib, and Incanter! > > The standalone autodoc tool is now available. It can be run from the > command line and it integrates with Leiningen and ant. (Maven still to > come - let me know if you want to help.) > > Autodoc builds full, styled HTML documentation from your doc-strings > and other metadata you supply. It includes a project overview page, > separate pages for each namespace, and an overall index page. > > It builds pages suitable for use with github pages so you can easily > publish documentation and can include links to source code if you > publish source. > > Documentation on how to get and use Autodoc is > here:http://tomfaulhaber.github.com/autodoc/(apologies for the fact that > the doc is not yet pretty!). > > I hope that Autodoc helps you increase the quality of documentation > for your projects. > > Enjoy, > > Tom Faulhaber -- 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 about Responsiveness of Garbage Collection
Thanks for the responses. It seems the consensus is that the slow responsiveness of Java apps is mostly due to an issue with Swing and how it is used rather than with garbage collection. That sounds very encouraging. The last point that interested me was: I heard someone mention that applications written using the Apple Java-Cocoa bridge was also noticeably less responsive than native applications in Objective-C, that person said it's because of java's GC though it seems that this is probably not the real culprit. What other reasons could there be the Java-Cocoa application being less responsive? Thanks -Patrick -- 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
What's the best way to do this?
I'm very new to Clojure, and to functional programming in general. Can anyone tell me the idiomatic way to implement this function? (defn find-files "Find files in directory that match predicates pred & others" [in-dir pred & others] (filter pred (file-seq in-dir))) What is the best way to filter a sequence using multiple predicates? I want to return a sequence containing the files that match predicate pred and all other predicates bound to 'others'. -- 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 about Responsiveness of Garbage Collection
> It seems the consensus is that the slow responsiveness of Java apps is > mostly due to an issue with Swing and how it is used rather than with > garbage collection. That sounds very encouraging. Determining whether the GC is responsible is pretty easy. Just runt with -verbose:gc (or -XX:+PrintGC) and watch the pauses. Unless your application has a very big heap I highly doubt GC is the problem. Whenever it is, you also have several options. The default GC selection in Sun's JVM is basically not at all catered to low-latency, instead focusing on throughput. Sun's JVM has the CMS collector which is targetted at limiting pauses with large heaps, and there is the upcoming G1GC collector. Non-Sun JVM:s have their own GC:s. In general, when people make off-hand remarks blaming the GC for random things, they are usually wrong and do not know what they are talking about. Until someone shows they have specifically identified the GC, I would take it with a grain of salt. If you do have GC problems you can select things other than the default collector. A potentially good starting point for CMS is: -XX:+UseConcMarkSweepGC \ -XX:+CMSIncrementalMode \ -XX:+CMSIncrementalPacing \ -XX:+PrintGCDetails \ -XX:+PrintGCTimeStamps \ -XX:+DisableExplicitGC \ -XX:+CMSParallelRemarkEnabled \ -XX:+TraceClassUnloading And for G1GC: -XX:+UnlockExperimentalVMOptions \ -XX:+UseG1GC \ -XX:+DisableExplicitGC \ -XX:MaxGCPauseMillis=10 \ -XX:GCPauseIntervalMillis=20 \ -XX:+G1ParallelRSetUpdatingEnabled \ -XX:+G1ParallelRSetScanningEnabled \ Often you will also get better behavior by using appropriate -Xms/-Xmx options. The above are just examples of course and not "the" way to do it or anything. The -XX:+DisableExplicitGC is because some software authors try to be "smart" and insert System.gc() calls at "appropriate" points. They tend to fail, so if you select a GC that actually does handle your case with minimal pauses you also want to disable the artificially induced full GC:s. -- / Peter Schuller -- 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: What's the best way to do this?
I'm not quite sure what you're getting at. Maybe split-with will do what you want? http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/split-with On Jan 21, 2:47 pm, nwalex wrote: > I'm very new to Clojure, and to functional programming in general. Can > anyone tell me the idiomatic way to implement this function? > > (defn find-files > "Find files in directory that match predicates pred & others" > [in-dir pred & others] > (filter pred (file-seq in-dir))) > > What is the best way to filter a sequence using multiple predicates? I > want to return a sequence containing the files that match predicate > pred and all other predicates bound to 'others'. -- 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: What's the best way to do this?
I don't know how efficient it is (or how idiomatic it really is), but this should work: (defn find-files "Find files in directory that match predicates pred & others" [in-dir pred & others] (reduce (fn [xs f] (filter f xs)) (file-seq in-dir) (cons pred others))) Dan On Thu, Jan 21, 2010 at 2:47 PM, nwalex wrote: > I'm very new to Clojure, and to functional programming in general. Can > anyone tell me the idiomatic way to implement this function? > > (defn find-files > "Find files in directory that match predicates pred & others" > [in-dir pred & others] > (filter pred (file-seq in-dir))) > > What is the best way to filter a sequence using multiple predicates? I > want to return a sequence containing the files that match predicate > pred and all other predicates bound to 'others'. > > -- > 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: What's the best way to do this?
Brilliant. Thanks Dan, that did the trick. On Jan 21, 8:01 pm, Dan Schmidt wrote: > I don't know how efficient it is (or how idiomatic it really is), but > this should work: > > (defn find-files > "Find files in directory that match predicates pred & others" > [in-dir pred & others] > (reduce (fn [xs f] (filter f xs)) (file-seq in-dir) (cons pred others))) > > Dan > > On Thu, Jan 21, 2010 at 2:47 PM, nwalex wrote: > > I'm very new to Clojure, and to functional programming in general. Can > > anyone tell me the idiomatic way to implement this function? > > > (defn find-files > > "Find files in directory that match predicates pred & others" > > [in-dir pred & others] > > (filter pred (file-seq in-dir))) > > > What is the best way to filter a sequence using multiple predicates? I > > want to return a sequence containing the files that match predicate > > pred and all other predicates bound to 'others'. > > > -- > > 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: Question about Responsiveness of Garbage Collection
> Often you will also get better behavior by using appropriate -Xms/-Xmx > options. The above are just examples of course and not "the" way to do > it or anything. i would like a JVM that has a "hot spot jit" for GC tweaking. -- 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: What's the best way to do this?
I think it's easier to think about combining predicates separately from your file-filtering code. I'd use a higher-order function like the following (defn combine-preds [& preds] (fn [& args] (every? #(apply % args) preds))) then filter files like (filter (combine-preds pred1 pred2) (file-seq in-dir)) Perry On Jan 21, 2:08 pm, nwalex wrote: > Brilliant. Thanks Dan, that did the trick. > > On Jan 21, 8:01 pm, Dan Schmidt wrote: > > > > > I don't know how efficient it is (or how idiomatic it really is), but > > this should work: > > > (defn find-files > > "Find files in directory that match predicates pred & others" > > [in-dir pred & others] > > (reduce (fn [xs f] (filter f xs)) (file-seq in-dir) (cons pred others))) > > > Dan > > > On Thu, Jan 21, 2010 at 2:47 PM, nwalex wrote: > > > I'm very new to Clojure, and to functional programming in general. Can > > > anyone tell me the idiomatic way to implement this function? > > > > (defn find-files > > > "Find files in directory that match predicates pred & others" > > > [in-dir pred & others] > > > (filter pred (file-seq in-dir))) > > > > What is the best way to filter a sequence using multiple predicates? I > > > want to return a sequence containing the files that match predicate > > > pred and all other predicates bound to 'others'. > > > > -- > > > 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: What's the best way to do this?
I agree with Perry. I've found I have to write two versions of combine-preds often (defn every-pred? "Mimics AND" [& preds] (fn [& args] (every? #(apply % args) preds))) (defn any-pred? "Mimics OR" [& preds] (fn [& args] (some #(apply % args) preds))) They're very handy, though. Makes it easy to create a complex predicate from simple ones. Sean On Jan 21, 3:40 pm, Perry Trolard wrote: > I think it's easier to think about combining predicates separately > from your file-filtering code. I'd use a higher-order function like > the following > > (defn combine-preds > [& preds] > (fn [& args] (every? #(apply % args) preds))) > > then filter files like > > (filter (combine-preds pred1 pred2) (file-seq in-dir)) > > Perry > > On Jan 21, 2:08 pm, nwalex wrote: > > > Brilliant. Thanks Dan, that did the trick. > > > On Jan 21, 8:01 pm, Dan Schmidt wrote: > > > > I don't know how efficient it is (or how idiomatic it really is), but > > > this should work: > > > > (defn find-files > > > "Find files in directory that match predicates pred & others" > > > [in-dir pred & others] > > > (reduce (fn [xs f] (filter f xs)) (file-seq in-dir) (cons pred others))) > > > > Dan > > > > On Thu, Jan 21, 2010 at 2:47 PM, nwalex wrote: > > > > I'm very new to Clojure, and to functional programming in general. Can > > > > anyone tell me the idiomatic way to implement this function? > > > > > (defn find-files > > > > "Find files in directory that match predicates pred & others" > > > > [in-dir pred & others] > > > > (filter pred (file-seq in-dir))) > > > > > What is the best way to filter a sequence using multiple predicates? I > > > > want to return a sequence containing the files that match predicate > > > > pred and all other predicates bound to 'others'. > > > > > -- > > > > 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: What's the best way to do this?
I think it's easier to think about combining predicates separately from your file-filtering code. I'd use a higher-order function like the following (defn combine-preds [& preds] (fn [& args] (every? #(apply % args) preds))) I've noticed that most uses of this kind of thing are for fixed sets of predicates, and almost always for two, so I'd define: (defmacro both [p1 p2] `(fn [& args#] (and (apply ~p1 args#) (apply ~p2 args# Which reads nicely: (filter (both number? even?) (range 1 7)) and is probably more efficient (not that I've tested it). You can generalize this to `all`, of course. -- 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: What's the best way to do this?
Not as a macro I hope. You lose apply. On Jan 21, 3:49 pm, Richard Newman wrote: > > I think it's easier to think about combining predicates separately > > from your file-filtering code. I'd use a higher-order function like > > the following > > > (defn combine-preds > > [& preds] > > (fn [& args] (every? #(apply % args) preds))) > > I've noticed that most uses of this kind of thing are for fixed sets > of predicates, and almost always for two, so I'd define: > > (defmacro both [p1 p2] > `(fn [& args#] > (and (apply ~p1 args#) > (apply ~p2 args# > > Which reads nicely: > > (filter (both number? even?) (range 1 7)) > > and is probably more efficient (not that I've tested it). > > You can generalize this to `all`, of course. -- 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 about Responsiveness of Garbage Collection
On Jan 21, 2010, at 19:08 , CuppoJava wrote: > The last point that interested me was: I heard someone mention that > applications written using the Apple Java-Cocoa bridge was also > noticeably less responsive than native applications in Objective-C, > that person said it's because of java's GC though it seems that this > is probably not the real culprit. What other reasons could there be > the Java-Cocoa application being less responsive? Objective-C is promoted hugely by apple, the entire libs, frameworks etc. are tailored for OS X. I would expect that about everything runs slower then Objective-C apps on OS X. Mind you as another point Java is still running in a VM and not natively as Obj-C code. Regards, Heinz-- 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
Replacing " with \" in a string.
Hi, I'm trying to write a simple function to replace every " inside the string with \", but am having an extremely difficult time. Can someone enlighten me as to why the following is returning true? (= (.replaceAll "\"" "\\\"" "a") (.replaceAll "\"" "\\\"" "\\a")) Thanks a lot -Patrick -- 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: Replacing " with \" in a string.
Your second "\\a" should probably be "\"a". On Jan 21, 5:40 pm, CuppoJava wrote: > Hi, > I'm trying to write a simple function to replace every " inside the > string with \", but am having an extremely difficult time. > > Can someone enlighten me as to why the following is returning true? > > (= (.replaceAll "\"" "\\\"" "a") > (.replaceAll "\"" "\\\"" "\\a")) > > Thanks a lot > -Patrick -- 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: Replacing " with \" in a string.
You have your arguments out of order, try: (= (.replaceAll "a" "\"" "\\\"") (.replaceAll "\\a" "\"" "\\\"")) On Thu, Jan 21, 2010 at 2:40 PM, CuppoJava wrote: > Hi, > I'm trying to write a simple function to replace every " inside the > string with \", but am having an extremely difficult time. > > Can someone enlighten me as to why the following is returning true? > > (= (.replaceAll "\"" "\\\"" "a") > (.replaceAll "\"" "\\\"" "\\a")) > > Thanks a lot > -Patrick > > -- > 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
loss-free print/read
Hello, Is there a way to do a loss free print/read loop in clojure?! I know that data structures like maps, vectors, .. maybe printed and read without the loss of information but it does not work for functions. Does clojure provide a the possibility to retrieve the data structure that represents a function?! Something like javascript's "toSource" or smalltalk's "decompile" method?! I saw that you might retrieve a function's string representation via a clojure.contrib.repl-utils function, but it requires the function to be available in a source file - it won't work with an anonymous function Thank you -- 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
Debugging in Clojure
Hi, I usually debug by adding println statements. How can I achieve the same effect in Clojure. I don't think I can introduce println at arbitrary places to figure out at which step is the algorithm failing. Thanks, Ajay -- 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
Dependency management
Hi folks, Apparently everyone is jumping on the Leiningen bandwagon and deleting their build.xml files. I guess that means I'm moving, too. Now, I like to keep track of Clojure master. Right now, Clojure reports "Clojure 1.2.0-master-SNAPSHOT". (I don't see that in Maven Central or in Clojars, so I guess I have to put it in my local repository...?) Unfortunately, not everybody keeps up-to-date like I do; most of the projects I use demand "1.1.0-alpha-SNAPSHOT". I'm sure there are still projects that demand 1.0. Adjusting the lein script to use my local Clojure install gave me a great error: Caused by: java.lang.NoSuchMethodError: clojure.lang.RestFn.(I)V at clojure.contrib.with_ns$with_ns__7929.(with_ns.clj:20) at clojure.contrib.with_ns__init.load(Unknown Source) at clojure.contrib.with_ns__init.(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at clojure.lang.RT.loadClassForName(RT.java:1523) at clojure.lang.RT.load(RT.java:396) at clojure.lang.RT.load(RT.java:378) at clojure.core$load__4869$fn__4876.invoke(core.clj:4294) at clojure.core$load__4869.doInvoke(core.clj:4293) at clojure.lang.RestFn.invoke(RestFn.java:409) at clojure.core$load_one__4810.invoke(core.clj:4130) at clojure.core$load_lib__4825.doInvoke(core.clj:4167) at clojure.lang.RestFn.applyTo(RestFn.java:143) at clojure.core$apply__3434.invoke(core.clj:478) at clojure.core$load_libs__4841.doInvoke(core.clj:4193) at clojure.lang.RestFn.applyTo(RestFn.java:138) at clojure.core$apply__3434.invoke(core.clj:480) at clojure.core$use__4865.doInvoke(core.clj:4271) at clojure.lang.RestFn.invoke(RestFn.java:409) at leiningen.core$eval__5$loading__4758__auto6.invoke(core.clj:1) at leiningen.core$eval__5.invoke(core.clj:1) at clojure.lang.Compiler.eval(Compiler.java:5349) and I saw a similar problem with builds that referred to libraries built with different versions of Clojure. How do people deal with this? How can one simultaneously use two libraries which have hardwired dependencies on two different Clojure versions, each of which might be mutually incompatible? What's the community protocol around locally installing Clojure 1.2, and adding that as a dependency for a published library? What's the right way to get lein itself to use a recent Clojure build, rather than the version with which it ships? Thoughts -- and answers! -- welcome. Thanks, -R -- 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: Debugging in Clojure
I usually debug by adding println statements. How can I achieve the same effect in Clojure. I don't think I can introduce println at arbitrary places to figure out at which step is the algorithm failing. Sure you can. You might need to add a (do ) block if you're wanting to add them in an (if), but that's no different to any other form in an (if). The only other consideration is laziness: your printlns might not fire when you think they should. -- 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: Debugging in Clojure
Is this the preferred way of debugging in Clojure? On Thu, Jan 21, 2010 at 5:25 PM, Richard Newman wrote: > I usually debug by adding println statements. How can I achieve the same >> effect in Clojure. I don't think I can introduce println at arbitrary places >> to figure out at which step is the algorithm failing. >> > > Sure you can. You might need to add a (do ) block if you're wanting to add > them in an (if), but that's no different to any other form in an (if). > > The only other consideration is laziness: your printlns might not fire when > you think they should. > > -- > 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: Dependency management
> What's the community protocol around locally installing Clojure 1.2, > and adding that as a dependency for a published library? I'll take a shot at this question. Clojure stresses immutability, and dependencies should be no different. I'd say it's bad form to force a dependency on an unreleased version of Clojure, because it's a moving target. Granted, there should be a mechanism for version 1.1.x, or 1.x so that libraries are forward compatible to a certain version. Just my $.02 Sean -- 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: Debugging in Clojure
I don't know about *the* preferred way, but it's my preferred way. It's a no-brainer to add print statements. I believe there is at least one logging library available too. On Jan 21, 7:27 pm, ajay gopalakrishnan wrote: > Is this the preferred way of debugging in Clojure? > > On Thu, Jan 21, 2010 at 5:25 PM, Richard Newman wrote: > > I usually debug by adding println statements. How can I achieve the same > >> effect in Clojure. I don't think I can introduce println at arbitrary > >> places > >> to figure out at which step is the algorithm failing. > > > Sure you can. You might need to add a (do ) block if you're wanting to add > > them in an (if), but that's no different to any other form in an (if). > > > The only other consideration is laziness: your printlns might not fire when > > you think they should. > > > -- > > 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: Debugging in Clojure
Logging side-effects usually occur within a do block, or the equivalent, e.g., when, catch. For production code, I'd suggest a logging library instead of filling your code with printlns. Contrib has a logging lib that delegates to common java logging libraries, but allows for writing them in a more idiomatic way. http://richhickey.github.com/clojure-contrib/logging-api.html On Jan 21, 5:14 pm, ajay gopalakrishnan wrote: > Hi, > > I usually debug by adding println statements. How can I achieve the same > effect in Clojure. I don't think I can introduce println at arbitrary places > to figure out at which step is the algorithm failing. > > Thanks, > Ajay -- 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
Proposal: New fn assoc-in-with
Sometimes you don't want assoc-in to create a hash-map. Sometimes you wish it could create a sorted map. Just finished working on something with Alexy Khrabrov & Chouser on IRC, and the three of us are wondering if the result might be generally useful. (defn assoc-in-with "supply a default-map instead of a hash-map" [m default-map [k & ks] v] (if ks (assoc m k (assoc-in-as (get m k default-map) default-map ks v)) (assoc m k v))) Also, is there room for a sister fn update-in-with? Thoughts? Sean -- 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: Dependency management
On Jan 21, 8:37 pm, Sean Devlin wrote: > Clojure stresses immutability, and dependencies should be no > different. I'd say it's bad form to force a dependency on an > unreleased version of Clojure, because it's a moving target. Granted, BTW, Clojure also stresses *controlled mutability*. I'd say it's bad form to impose a value judgment in place of a technical solution. If some 1.2 features make for a better project development experience, why rule them out? -- 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
Parallel activities
What is the clojure idiom for running multiple (in this case IO bound) functions simultaneously? My use case is the parallel activities are coordinated, basically running in lockstep. I've been using (.start (Thread. myfn)). It works, but I'm wondering if there's a better way. The data shared between the threads is stored in an agent, which sort of suggests send-off to me, but I can't find any reason to think that send-off runs everything in parallel. Any thoughts would be welcome. -- 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: Debugging in Clojure
I find that injecting print statements is painful if you're not using something like paredit (Emacs). With paredit it's quite simple. On Thu, Jan 21, 2010 at 8:27 PM, ajay gopalakrishnan wrote: > Is this the preferred way of debugging in Clojure? > > > On Thu, Jan 21, 2010 at 5:25 PM, Richard Newman wrote: > >> I usually debug by adding println statements. How can I achieve the same >>> effect in Clojure. I don't think I can introduce println at arbitrary places >>> to figure out at which step is the algorithm failing. >>> >> >> Sure you can. You might need to add a (do ) block if you're wanting to add >> them in an (if), but that's no different to any other form in an (if). >> >> The only other consideration is laziness: your printlns might not fire >> when you think they should. >> >> -- >> 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 > -- 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: Dependency management
We're not all jumping on Leiningen, some of us are sticking with maven, using the maven-clojure-compiler plugin, and also the experimental Maven Polyglot Clojure build support: http://polyglot.sonatype.org/clojure.html (disclojure - both of these are my projects so I'm somewhat biased) -- Pull me down under... On Fri, Jan 22, 2010 at 2:21 PM, Richard Newman wrote: > Apparently everyone is jumping on the Leiningen bandwagon and deleting their > build.xml files. I guess that means I'm moving, too. -- 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: What's the best way to do this?
I agree, one possible improvement would be short circuiting on the first false pred. (defn combine-preds [pred & others] (fn [v] (loop [result true pred pred others others] (if (not result) result (if (nil? pred) result (recur (pred v) (first others) (rest others))) (defn mod2 [n] (zero? (mod n 2))) (defn mod3 [n] (zero? (mod n 3))) ((combine-preds mod2 mod3) 6) ; true, checks both ((combine-preds mod2 mod3) 9) ; false, never gets past first pred On Thu, Jan 21, 2010 at 3:40 PM, Perry Trolard wrote: > I think it's easier to think about combining predicates separately > from your file-filtering code. I'd use a higher-order function like > the following > > (defn combine-preds >[& preds] >(fn [& args] (every? #(apply % args) preds))) > > then filter files like > > (filter (combine-preds pred1 pred2) (file-seq in-dir)) > > Perry > > > > On Jan 21, 2:08 pm, nwalex wrote: > > Brilliant. Thanks Dan, that did the trick. > > > > On Jan 21, 8:01 pm, Dan Schmidt wrote: > > > > > > > > > I don't know how efficient it is (or how idiomatic it really is), but > > > this should work: > > > > > (defn find-files > > > "Find files in directory that match predicates pred & others" > > > [in-dir pred & others] > > > (reduce (fn [xs f] (filter f xs)) (file-seq in-dir) (cons pred > others))) > > > > > Dan > > > > > On Thu, Jan 21, 2010 at 2:47 PM, nwalex > wrote: > > > > I'm very new to Clojure, and to functional programming in general. > Can > > > > anyone tell me the idiomatic way to implement this function? > > > > > > (defn find-files > > > > "Find files in directory that match predicates pred & others" > > > > [in-dir pred & others] > > > > (filter pred (file-seq in-dir))) > > > > > > What is the best way to filter a sequence using multiple predicates? > I > > > > want to return a sequence containing the files that match predicate > > > > pred and all other predicates bound to 'others'. > > > > > > -- > > > > 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 > -- 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: Dependency management
We're not all jumping on Leiningen, some of us are sticking with maven, using the maven-clojure-compiler plugin, and also the experimental Maven Polyglot Clojure build support: It's not the "Leiningen" that's important, it's the "jumping": away from Ant, not Maven. Every library I use had an Ant build script. I never saw a POM. (Apologies for this diversion. Maybe it'll be of interest to some on this list.) I'm somewhat swayed by Leiningen because it makes doing some things easy (uberjar! starting a REPL! neat!), at the cost of making other things (such as managing dependencies myself) more frustrating. However, if it wasn't for all the people blindly deleting their Ant build scripts, I would be sticking with my Ant workflow for another few months. I don't think Lein is quite targeted at users like me.* That's OK, and I'm sure it'll change over time. I'm looking forward to more plugins arriving to perhaps allow me to define per-project tasks (for database operations, say). I'm not at all swayed by Maven itself. XML *and* bloated opaque dependency management! What's not to love? (Yes, I know it does a lot of cool stuff -- http://blog.lick-me.org/2010/01/maven-sucks/ is a good start on the pros and cons -- I just don't care about most of that stuff, and I do care about the horrible parts.) http://polyglot.sonatype.org/clojure.html That certainly makes Maven's syntax less repellent, but it still has Maven underneath. -R * For those who might ask "and what kind of user are you?": * I keep up to date with Clojure master. I don't use binary releases. * I fix bugs and make changes in my local Clojure/contrib/third- party library trees, and I want *all* of my builds to use *those*, not their own choice of versions. With lein/mvn I have to install a custom version of those libraries into my repo, then change all of my libraries to use the custom version. New build = changing every library's project file again (or overwriting the repo version... not sure how acceptable a solution that is). With my previous approach I simply had to overwrite a jar (allowing my VCS to track the old version). * I prefer using Git commit IDs to unambiguously reference versions, not an arbitrary version string which I have to change in a separate commit. * I run arbitrary Ant tasks -- such as SQL scripts -- in my projects. I don't see that in Leiningen. I'd love someone to point me to it. * Not all of my projects are open-source, so I like to store their cross-dependencies in version control, not in some custom repository server. I don't want to have to figure out how to run my own Maven repo somewhere, solving the auth problem again, etc. etc. -- 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: What's the best way to do this?
I agree, one possible improvement would be short circuiting on the first false pred. every? does short-circuit. user=> (every? #(% 5) (list (fn [a] (println "First a: " a) false) (fn [a] (println "Second a: " a) true))) First a: 5 false -- 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: What's the best way to do this?
Oops you're right :) And better written as well :D On Fri, Jan 22, 2010 at 1:26 AM, Richard Newman wrote: > I agree, one possible improvement would be short circuiting on the first >> false pred. >> > > every? does short-circuit. > > user=> (every? #(% 5) > (list > (fn [a] (println "First a: " a) false) > (fn [a] (println "Second a: " a) true))) > > First a: 5 > false > > -- > 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: Dependency management
Richard Newman writes: > Adjusting the lein script to use my local Clojure install gave me a > great error: > > Caused by: java.lang.NoSuchMethodError: clojure.lang.RestFn.(I)V > > How do people deal with this? How can one simultaneously use two > libraries which have hardwired dependencies on two different Clojure > versions, each of which might be mutually incompatible? > > What's the community protocol around locally installing Clojure 1.2, > and adding that as a dependency for a published library? It's necessary in these circumstances to use AOT as sparingly as possible. If there's no AOT done, there's no problem with mixing Clojure versions (within reason). So the latest version of Leiningen does zero AOT'ing unless you explicitly ask for it. > What's the right way to get lein itself to use a recent Clojure build, > rather than the version with which it ships? Leiningen allows the project to use a different version of Clojure than Leiningen itself, so (modulo a bug in the repl task for which this doesn't apply) this is a non-issue. -Phil -- 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: Dependency management
How do people deal with this? How can one simultaneously use two libraries which have hardwired dependencies on two different Clojure versions, each of which might be mutually incompatible? What's the community protocol around locally installing Clojure 1.2, and adding that as a dependency for a published library? It's necessary in these circumstances to use AOT as sparingly as possible. If there's no AOT done, there's no problem with mixing Clojure versions (within reason). So the latest version of Leiningen does zero AOT'ing unless you explicitly ask for it. That wasn't quite my question. Say I rely on a particular feature in 1.2, perhaps commit b63af1ad6ce38b50552be3c424ea166cb063ee7c Author: Chouser Date: Mon Jan 11 02:04:32 2010 -0500 Add agent error handlers and error modes :fail and :continue. Fixes #30 My code doesn't work on 1.1 or earlier. * How can I express a dependency in a published library for a library which has not been published? Tough question. People will be annoyed if I upload my own build of 1.2, then don't fix my POM when Clojure 1.2 is officialy released. * What happens when someone else's code -- which explicitly specifies Clojure 1.1 -- wants to use my library? If one uses AOT, you might get some odd stack trace. If one does not use AOT, you get a compile error. Much better solutions are "you get a warning", or "you can specify a range of allowable versions, and the build software chooses the right version". This is a hard problem, and any dependency management system which requires you to pick a single version of a dependency, when multiple versions exist (and your code might work on more than one) is going to hit it. I don't think "everybody has to upgrade at once" is a good solution. What's the right way to get lein itself to use a recent Clojure build, rather than the version with which it ships? Leiningen allows the project to use a different version of Clojure than Leiningen itself, so (modulo a bug in the repl task for which this doesn't apply) this is a non-issue. Thanks for clarifying. It appears that it does not work with 1.2, because running `lein` after changing CLOJURE_JAR to point to my 1.2 build caused that error to occur! -R -- 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: function to perform operations on adjacent values
2010/1/21 Chris Kent : > partition creates a sequence of sequences of adjacent values > > user=> (partition 2 (range 1 7)) > ((1 2) (3 4) (5 6)) > > and you can apply reduce to each of the sequences using map > > user=> (map #(reduce + %) (partition 2 (range 1 7))) > (3 7 11) > > or > > user=> (map (partial reduce + ) (partition 2 (range 1 7))) > (3 7 11) For a slightly different (but less general, perhaps) version, there's also: (map (fn [[a b]] (+ a b)) (partition 2 (range 1 7))) By the way, don't get caught out by this: user=> (partition 2 (range 1 7)) ((1 2) (3 4) (5 6)) user=> (partition 2 (range 1 8)) ((1 2) (3 4) (5 6)) user=> (partition 2 (range 1 9)) ((1 2) (3 4) (5 6) (7 8)) -- 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