Re: popping optional args from the front
On 30 Dec 2009, at 02:36, Joost wrote: Personally, I prefer to use multple prototypes: (defn bla ([aaa bbb ccc] ) ([bbb cc] (bla 0 bbb cc))) etc. That's the preferred approach for me too, but it doesn't work for functions that take a variable number of arguments. 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: Processing list more elegantly
2009/12/30 Rich Hickey richhic...@gmail.com: This was discussed before, the new version never made it into a patch: http://groups.google.com/group/clojure/msg/43de40f078a291cc Great! The 'old' reductions behaves slightly different from the 'new' reductions for the 3 argument form: foo= (reductions + 0 [3 5 10 1 2 7]) (0 3 8 18 19 21 28) foo= (reductions2 + 0 [3 5 10 1 2 7]) (3 8 18 19 21 28) Which output is more correct? On the one hand supplying a preserved 'initial value' from outside does not make much sense, but on the other hand perhaps it is more in step with 3 argument reduce. Does it matter? Probably not. It does provide an interesting case study. The 3 argument form could be considered just a helper to achieve the 2 argument form, but because it is part of the public interface people may chose to rely on it: (defn left-total3 [coll] (map list coll (reductions + 0 coll))) might have been better written as (defn left-total3 [coll] (map list coll (cons 0 (reductions + coll So is exposing the 3 argument version a bad thing? It is not very idiomatic to use the alternatives: (let-fn [(reducer [f acc coll] ...)] (defn reductions [f coll] ... reducer ...)) And then again if I can call (reduce + 3 [1 2]) maybe it is reasonable to call (reductions + 3 [1 2]) I'm over analyzing what is really a non-issue, but just found it thought provoking. Back to more practical concerns, attached is a modified version for consideration which preserves the old behavior but is faster. Happy to supply a git patch if on the right track - let me know what is best :) Regards, Tim. -- 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;; reductions by Chris Houser ;; http://groups.google.com/group/clojure/browse_thread/thread/3edf6e82617e18e0 ;; improved by Stuart Holloway and Rich Hickey and Mark Engelberg ;; http://groups.google.com/group/clojure/browse_thread/thread/2be768e15d2b717a ;; made backward compatible by Timothy Pratley ;; http://groups.google.com/group/clojure/browse_thread/thread/3e37df49ce5edf44 (defn reductions Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f. If an initial value init is supplied, it will be at the front of the sequence. ([f coll] (lazy-seq (if-let [s (seq coll)] (reductions f (first s) (rest s)) (cons (f) nil ([f acc coll] (lazy-seq (if-let [s (seq coll)] (cons acc (reductions f (f acc (first s)) (rest s))) (cons acc nil)
Re: update-in and get-in why no default?
On Dec 13, 1:24 am, Rich Hickey richhic...@gmail.com wrote: fnil seems to me to have greater utility than patching all functions that apply functions with default-supplying arguments. Neat :) I like it. The get-in function could be enhanced, and would mirror get. Should I interpret 'could' as 'patch welcome' or 'let me think about it'? Regards, Tim. -- 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 positions available
More specifically Developer positions with a major Clojure focus at our Durham, NC, USA office. Relevance is also doing a lot of Ruby, plus some C, Java, and a smattering of other things. Learn more about Relevance at http://howwework.thinkrelevance.com/. If you are interested tell us about yourself via email to jobs at thinkrelevance dot com. Stu -- 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: Getting started with few Java knowledge
I already tried fat jar, but failed... 2009/12/29 Laurent PETIT laurent.pe...@gmail.com: On the counterclockwise main page : http://code.google.com/p/counterclockwise/ , There's a right box named Groups where you'll find the user developers group. For your particular problem, you can also check the ccw documentation wiki page, and especially the section related to creating Fat executable jars via the use of a third-party eclipse plugin named Fat Jar ( http://code.google.com/p/counterclockwise/wiki/Documentation#Package_your_work ) Cheers, -- Laurent 2009/12/28 Joop Kiefte iko...@gmail.com Thanks for the encouragement! Where can I join the list? 2009/12/28 Laurent PETIT laurent.pe...@gmail.com: OK I think I understand. As an open source project written on free-time, ccw is open to any contribution. Especially, newcomers to Java (and presumably Eclipse) such as you, which will find big wholes in documentation or usability, are invited to contribute : you can discuss things on ccw user's ml, file tickets in ccw's google group ticket system, propose enhancements to the documentation, etc. Help welcome ! -- Laurent 2009/12/28 Joop Kiefte iko...@gmail.com I am just clueless in CCW how to get it compiled nicely. It doesn't get you started with the files you need minimally to get it compiled correctly and I remain clueless on how to get it to work. And I get duplicated files probably because of eclipse works (include every compiled file in the project as it is in the same directory). I got lost there =x. At least I would like to see a basic workflow document about CCW, and better of course to have it nicely built in in Eclipse. I hope you understand what I mean... 2009/12/28 Laurent PETIT laurent.pe...@gmail.com: 2009/12/28 Joop Kiefte iko...@gmail.com [...] I think this works a lot nicer than CCW. [...] As a ccw contributor, I would be pleased if you could you elaborate on this ? What does it mean to be a lot nicer than CCW ? Is it you would like that ccw, when creating a new clojure project, also creates a basic ant script to be able to compile your project independently of ccw's out-of-the-box eclipse builder ? Is it something else ? Thanks, -- Laurent -- 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 -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... - http://esperanto.net - http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- 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 -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... - http://esperanto.net - http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- 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
Clojure + Redis
On first look, Redis and Clojure seems to be a perfect match. They both handle sets and maps efficiently. If one could find an easy way to store and retrieve Clojure data structures to Redis (even a small subset- just a list or a set), a distributed clojure app could be very easy (and effective?) thing to do - The stateless Clojure nodes would share and operate on the same central data structure which is stored in Redis). What do you thing ? Is it worth investigating further? -- 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 + Redis
I think anything which lowers the impedance mismatch between Clojure data structures and a persistent store is worth investigating. I'd love to find an ACID, transactional store which accepts native structures. Right now I'm using CouchDB, and while JSON is close enough, it still requires a mapping between the Clojure and Couch worlds. Not supporting set, and not allowing fields with dashes (JavaScript thinks it's a minus) are some of the annoyances. On Wed, Dec 30, 2009 at 12:52 PM, Gabi bugspy...@gmail.com wrote: On first look, Redis and Clojure seems to be a perfect match. They both handle sets and maps efficiently. If one could find an easy way to store and retrieve Clojure data structures to Redis (even a small subset- just a list or a set), a distributed clojure app could be very easy (and effective?) thing to do - The stateless Clojure nodes would share and operate on the same central data structure which is stored in Redis). What do you thing ? Is it worth investigating further? -- 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
leiningen plugins and scripting
Hello, I'm moving a small project over from maven built scala to leiningen built clojure. One of the features that was available with the maven scala plugin was the ability to run scala scripts: mvn scala:script -DscriptFile=scripts/build_db.scala This is useful for doing project specific tasks that are too specialised for a plugin such as downloading content or sending emails. It would be really cool to be able to do something like this in leiningen. One idea I had was to have a leingingen plugin in my src directory with the namespace leingingen.builddb and then simply call: lein builddb However, as far as I can tell, the classpath of the compiled source code is not available to leingingen while building. Another option is to develop a script plugin and run a command such as: lein script scripts/builddb.clj Is this a feature anybody else would be interested in? Are there any views on what the best approach would be? Thanks in advance 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: leiningen javac plugin
On Dec 9, 7:53 am, antoniogarrote listasantoniogarr...@gmail.com wrote: A quick and dirty hack to compile java files in clojure projects usingleiningen. Just run $lein compile-java to transforms 'src/**.java' into 'classes/ **.class' Many thanks. This works for me and I find it useful. However, in a perfect world: lein compile would also compile my java source code or call compile-java before performing a compile. In fact in this perfect world: lein swank would download all dependencies, compile java files and then start a swank server. Is there anyway to get leiningen plugins to depend on each other or has this behaviour been omitted by design? 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
strange typecheck error
Hello all I have strange problem with type inference in Clojure. I have following code (simplified version of real code), (defn- process-char [#^InputStream istream] (let [ch (.read istream)] (if (= ch 10) AAA ch))) (defn- process-text [#^InputStream istream] (loop [char (.read istream)] (let [result (process-char istream)] (cond ;; .. some additional conditions (string? result) (loop (.read istream)) (number? result) (loop result) ... Main idea, that in some function, i read characters in sequence, and check their values, and in some conditions, i need to re-submit already readed character into loop, but when i use code above, i get following error: java.lang.IllegalArgumentException: recur arg for primitive local: char must be matching primitive [Thrown class java.lang.RuntimeException] but if i replace (loop result) with (.read istream), then it works without any problems I checked type of result, and it's Integer - same type, that 'char' var in loop will get after reading from stream. If need, i can submit somebody full test case -- With best wishes, Alex Ott, MBA http://alexott.blogspot.com/http://xtalk.msk.su/~ott/ http://alexott-ru.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: strange typecheck error
Is process char returns char or String? --Original Message-- From: Alex Ott Sender: clojure@googlegroups.com To: Clojure ML ReplyTo: clojure@googlegroups.com Subject: strange typecheck error Sent: Dec 30, 2009 19:53 Hello all I have strange problem with type inference in Clojure. I have following code (simplified version of real code), (defn- process-char [#^InputStream istream] (let [ch (.read istream)] (if (= ch 10) AAA ch))) (defn- process-text [#^InputStream istream] (loop [char (.read istream)] (let [result (process-char istream)] (cond ;; .. some additional conditions (string? result) (loop (.read istream)) (number? result) (loop result) ... Main idea, that in some function, i read characters in sequence, and check their values, and in some conditions, i need to re-submit already readed character into loop, but when i use code above, i get following error: java.lang.IllegalArgumentException: recur arg for primitive local: char must be matching primitive [Thrown class java.lang.RuntimeException] but if i replace (loop result) with (.read istream), then it works without any problems I checked type of result, and it's Integer - same type, that 'char' var in loop will get after reading from stream. If need, i can submit somebody full test case -- With best wishes, Alex Ott, MBA http://alexott.blogspot.com/http://xtalk.msk.su/~ott/ http://alexott-ru.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 Sent from my BlackBerry® wireless device -- 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: seeking rudimentary defprotocol + deftype help
Did you try: (deftype B [#^::A Avalue])? I don't know whether this works, but it's the obvious idea. http://stackoverflow.com/questions/1976423/nested-types-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: strange typecheck error
Sorry, I'm confused by the code sample. I see several loops but no corresponding recurs. On Dec 30, 11:53 am, Alex Ott alex...@gmail.com wrote: Hello all I have strange problem with type inference in Clojure. I have following code (simplified version of real code), (defn- process-char [#^InputStream istream] (let [ch (.read istream)] (if (= ch 10) AAA ch))) (defn- process-text [#^InputStream istream] (loop [char (.read istream)] (let [result (process-char istream)] (cond ;; .. some additional conditions (string? result) (loop (.read istream)) (number? result) (loop result) ... Main idea, that in some function, i read characters in sequence, and check their values, and in some conditions, i need to re-submit already readed character into loop, but when i use code above, i get following error: java.lang.IllegalArgumentException: recur arg for primitive local: char must be matching primitive [Thrown class java.lang.RuntimeException] but if i replace (loop result) with (.read istream), then it works without any problems I checked type of result, and it's Integer - same type, that 'char' var in loop will get after reading from stream. If need, i can submit somebody full test case -- With best wishes, Alex Ott, MBAhttp://alexott.blogspot.com/ http://xtalk.msk.su/~ott/http://alexott-ru.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: merge doesn't work on deftypes implementing IPersistentMap
i'm hoping the yet part means it is slated to maybe someday be upgraded? I've filed a bug and submitted a patch. Assuming my fix is acceptable, this should be in soon. https://www.assembla.com/spaces/clojure/tickets/231-deftype-cons-doesn-t-support-maps- -- 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: leiningen javac plugin
Saul shaz...@gmail.com writes: On Dec 9, 7:53 am, antoniogarrote listasantoniogarr...@gmail.com wrote: A quick and dirty hack to compile java files in clojure projects usingleiningen. Just run $lein compile-java to transforms 'src/**.java' into 'classes/ **.class' Many thanks. This works for me and I find it useful. However, in a perfect world: lein compile would also compile my java source code or call compile-java before performing a compile. In fact in this perfect world: lein swank would download all dependencies, compile java files and then start a swank server. Is there anyway to get leiningen plugins to depend on each other or has this behaviour been omitted by design? If you mean something like Maven build lifecycle then I hope it will be never implemented in Leiningen. I really like tools, which by default do exactly what I asked for. lein jar should only mean please create jar on the basis of explicte specification, nothing more nothing less. I guess this sentence from Leiningen README: Leiningen is a build tool for Clojure designed to not set your hair on fire. was inspired by tools being smarter than developer. ;) If you mean explicit joining of commands, e.g.: $ lein clean compile-java compile jar or somehow in project.clj then I'm all in favour of this approach. Br, Rob -- 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 + Redis
There are other NoSQL datastores written in java, like Voldemort. Perhaps if you investigate them, you will find one that will be much easier to integrate with 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: seeking rudimentary defprotocol + deftype help
p.p.s. i was using -alpha- and changed to -new- (and pulled today) and now i get a slightly different error. am i just flubbing the syntax in some way i can't see for the trees?! user= (defprotocol P (foo [x])) P user= (deftype A [] [P] (.foo [x])) java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.Symbol (NO_SOURCE_FILE:0) On Tue, Dec 29, 2009 at 12:08 PM, Raoul Duke rao...@gmail.com wrote: i haven't been able to figure out what i'm doing wrong yet. the error message isn't super helpful :-} Clojure 1.1.0-alpha-SNAPSHOT user= (defprotocol P (foo [x])) P user= (deftype T [f] [P] (foo [x] x)) java.lang.ClassCastException: clojure.lang.Var cannot be cast to java.lang.Class (NO_SOURCE_FILE:2) ?! thanks for any help. -- 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
Status of bounded search on sorted-map?
About a year and a half ago, there was some discussion about having a function that would enable some kind of bounded search on a sorted map: http://groups.google.com/group/clojure/browse_thread/thread/949cae6c085d3d39/65b4082085c19a60?q= Does this exist, currently? I haven't looked at the gory details of PersistentTreeMap, so I don't know how difficult this would be to do. Intuitively though, since we have the keys are in a sorted tree, I thought that it would be possible to have a bounded search in something like O(log n). Rob p.s. I asked a related question on stackoverflow: http://stackoverflow.com/questions/1981859/finding-keys-closest-to-a-given-value-for-clojure-sorted-maps -- 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: seeking rudimentary defprotocol + deftype help
Thanks alot guys! On Dec 30, 1:41 pm, Raoul Duke rao...@gmail.com wrote: p.p.s. i was using -alpha- and changed to -new- (and pulled today) and now i get a slightly different error. am i just flubbing the syntax in some way i can't see for the trees?! user= (defprotocol P (foo [x])) P user= (deftype A [] [P] (.foo [x])) java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.Symbol (NO_SOURCE_FILE:0) On Tue, Dec 29, 2009 at 12:08 PM, Raoul Duke rao...@gmail.com wrote: i haven't been able to figure out what i'm doing wrong yet. the error message isn't super helpful :-} Clojure 1.1.0-alpha-SNAPSHOT user= (defprotocol P (foo [x])) P user= (deftype T [f] [P] (foo [x] x)) java.lang.ClassCastException: clojure.lang.Var cannot be cast to java.lang.Class (NO_SOURCE_FILE:2) ?! thanks for any help. -- 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: Status of bounded search on sorted-map?
Use a combination of take-while key (take-while (comp your-pred key) sorted-map) You could also use drop while as needed. I've got a blog post where I use this to solve the knapsack problem: http://fulldisclojure.blogspot.com/2009/12/uses-for-takedrop-while.html I've got some other stuff, too. Send me a note if you need more than this. Sean On Dec 30, 5:37 pm, Rob Lachlan robertlach...@gmail.com wrote: About a year and a half ago, there was some discussion about having a function that would enable some kind of bounded search on a sorted map: http://groups.google.com/group/clojure/browse_thread/thread/949cae6c0... Does this exist, currently? I haven't looked at the gory details of PersistentTreeMap, so I don't know how difficult this would be to do. Intuitively though, since we have the keys are in a sorted tree, I thought that it would be possible to have a bounded search in something like O(log n). Rob p.s. I asked a related question on stackoverflow: http://stackoverflow.com/questions/1981859/finding-keys-closest-to-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: Status of bounded search on sorted-map?
This would work, but would require iterating over the keys, for something like O(n) performance. I'm hoping that we can do better, since the keys are already in an ordered collection. On Dec 30, 3:04 pm, Sean Devlin francoisdev...@gmail.com wrote: Use a combination of take-while key (take-while (comp your-pred key) sorted-map) You could also use drop while as needed. I've got a blog post where I use this to solve the knapsack problem: http://fulldisclojure.blogspot.com/2009/12/uses-for-takedrop-while.html I've got some other stuff, too. Send me a note if you need more than this. Sean On Dec 30, 5:37 pm, Rob Lachlan robertlach...@gmail.com wrote: About a year and a half ago, there was some discussion about having a function that would enable some kind of bounded search on a sorted map: http://groups.google.com/group/clojure/browse_thread/thread/949cae6c0... Does this exist, currently? I haven't looked at the gory details of PersistentTreeMap, so I don't know how difficult this would be to do. Intuitively though, since we have the keys are in a sorted tree, I thought that it would be possible to have a bounded search in something like O(log n). Rob p.s. I asked a related question on stackoverflow: http://stackoverflow.com/questions/1981859/finding-keys-closest-to-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: Status of bounded search on sorted-map?
I should have said: since the keys are already in a tree. If they were in a linked list, I'd expect to have to iterate over most of the list. On Dec 30, 3:10 pm, Rob Lachlan robertlach...@gmail.com wrote: This would work, but would require iterating over the keys, for something like O(n) performance. I'm hoping that we can do better, since the keys are already in an ordered collection. On Dec 30, 3:04 pm, Sean Devlin francoisdev...@gmail.com wrote: Use a combination of take-while key (take-while (comp your-pred key) sorted-map) You could also use drop while as needed. I've got a blog post where I use this to solve the knapsack problem: http://fulldisclojure.blogspot.com/2009/12/uses-for-takedrop-while.html I've got some other stuff, too. Send me a note if you need more than this. Sean On Dec 30, 5:37 pm, Rob Lachlan robertlach...@gmail.com wrote: About a year and a half ago, there was some discussion about having a function that would enable some kind of bounded search on a sorted map: http://groups.google.com/group/clojure/browse_thread/thread/949cae6c0... Does this exist, currently? I haven't looked at the gory details of PersistentTreeMap, so I don't know how difficult this would be to do. Intuitively though, since we have the keys are in a sorted tree, I thought that it would be possible to have a bounded search in something like O(log n). Rob p.s. I asked a related question on stackoverflow: http://stackoverflow.com/questions/1981859/finding-keys-closest-to-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: Status of bounded search on sorted-map?
Do you need persistence? There's a solution in java.util in Java 6. On Dec 30, 6:10 pm, Rob Lachlan robertlach...@gmail.com wrote: This would work, but would require iterating over the keys, for something like O(n) performance. I'm hoping that we can do better, since the keys are already in an ordered collection. On Dec 30, 3:04 pm, Sean Devlin francoisdev...@gmail.com wrote: Use a combination of take-while key (take-while (comp your-pred key) sorted-map) You could also use drop while as needed. I've got a blog post where I use this to solve the knapsack problem: http://fulldisclojure.blogspot.com/2009/12/uses-for-takedrop-while.html I've got some other stuff, too. Send me a note if you need more than this. Sean On Dec 30, 5:37 pm, Rob Lachlan robertlach...@gmail.com wrote: About a year and a half ago, there was some discussion about having a function that would enable some kind of bounded search on a sorted map: http://groups.google.com/group/clojure/browse_thread/thread/949cae6c0... Does this exist, currently? I haven't looked at the gory details of PersistentTreeMap, so I don't know how difficult this would be to do. Intuitively though, since we have the keys are in a sorted tree, I thought that it would be possible to have a bounded search in something like O(log n). Rob p.s. I asked a related question on stackoverflow: http://stackoverflow.com/questions/1981859/finding-keys-closest-to-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: Status of bounded search on sorted-map?
Thanks for the pointer. I had a feeling that java world had something like this, but I'd much prefer to be able to do this from clojure. Appreciate the info, though. On Dec 30, 3:14 pm, Sean Devlin francoisdev...@gmail.com wrote: Do you need persistence? There's a solution in java.util in Java 6. On Dec 30, 6:10 pm, Rob Lachlan robertlach...@gmail.com wrote: This would work, but would require iterating over the keys, for something like O(n) performance. I'm hoping that we can do better, since the keys are already in an ordered collection. On Dec 30, 3:04 pm, Sean Devlin francoisdev...@gmail.com wrote: Use a combination of take-while key (take-while (comp your-pred key) sorted-map) You could also use drop while as needed. I've got a blog post where I use this to solve the knapsack problem: http://fulldisclojure.blogspot.com/2009/12/uses-for-takedrop-while.html I've got some other stuff, too. Send me a note if you need more than this. Sean On Dec 30, 5:37 pm, Rob Lachlan robertlach...@gmail.com wrote: About a year and a half ago, there was some discussion about having a function that would enable some kind of bounded search on a sorted map: http://groups.google.com/group/clojure/browse_thread/thread/949cae6c0... Does this exist, currently? I haven't looked at the gory details of PersistentTreeMap, so I don't know how difficult this would be to do. Intuitively though, since we have the keys are in a sorted tree, I thought that it would be possible to have a bounded search in something like O(log n). Rob p.s. I asked a related question on stackoverflow: http://stackoverflow.com/questions/1981859/finding-keys-closest-to-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: strange typecheck error
On Dec 30, 12:53 pm, Alex Ott alex...@gmail.com wrote: If need, i can submit somebody full test case I think this might help because it's hard to tell what you are trying to do without a little more context. Some odd things that stand out to me: 1) You call loop, but you should be calling recur. E.g. (loop result) 2) Why are the arguments streams and not readers? 3) You do nothing with the 'char' variable binding. My guess is you just made some typos while trying to create a simple example. -- 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: leiningen javac plugin
On Dec 30, 8:46 pm, Rob Wolfe r...@smsnet.pl wrote: Saul shaz...@gmail.com writes: Many thanks. This works for me and I find it useful. However, in a perfect world: lein compile would also compile my java source code or call compile-java before performing a compile. If you mean something like Maven build lifecycle then I hope it will be never implemented in Leiningen. I really like tools, which by default do exactly what I asked for. lein jar should only mean please create jar on the basis of explicte specification, nothing more nothing less. I can imagine the maven way of doing things is a pain for plugin developers. However, I have recently moved from the scala maven plugin (which compiles java source automatically) to the clojure maven plugin (which requires an explicit 'mvn compile' to compile java source). I hit two problems where I forgot to compile the java code and thought I was seeing bugs. Its definitely user error (which I can work around) but its worth pointing out that older tools like 'make' would support me in such situations. If you mean explicit joining of commands, e.g.: $ lein clean compile-java compile jar or somehow in project.clj then I'm all in favour of this approach. I also like this idea but it does make passing parameters to plugins harder. Although I haven't seen any plugins that use parameters yet. Thanks very much for your reply. 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: Status of bounded search on sorted-map?
2009/12/31 Rob Lachlan robertlach...@gmail.com: About a year and a half ago, there was some discussion about having a function that would enable some kind of bounded search on a sorted Does this exist, currently? I haven't looked at the gory details of subseq and rsubseq provide efficient bounded searching. I don't see the need for find or seek as that is really just (first (subseq sm)) For your particular problem (find closest) a combination of first subseq = and first rsubseq = will find you the two best candidates on either side, and thus which is closest. However this is slightly more work than if you could just do one efficient search and then access the key to the other side of the test... which is a different proposition all together than bounded search but if it is useful sounds easy enough to expose. Currently you can access the tree itself (.tree sm) works, but you can't find out what's to the left or right because those are private. Do you want to navigate the tree, or would a left and right search suffice? Regards, Tim. -- 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
Google-collections
I wonder if just released http://code.google.com/p/google-collections/ google-collections java library could be of any use to clojure implementation ? They have there High-performance immutable implementations of the standard collection types and many other goodies. -- 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: Status of bounded search on sorted-map?
Thanks very much, that makes a lot of sense. I looked through the java code for PersistentTreeMap, and indeed those methods are private. I think that I'll be happy with subseq and rsubseq. Being a noob, it hadn't occured to me that I could do that. On Dec 30, 8:04 pm, Timothy Pratley timothyprat...@gmail.com wrote: 2009/12/31 Rob Lachlan robertlach...@gmail.com: About a year and a half ago, there was some discussion about having a function that would enable some kind of bounded search on a sorted Does this exist, currently? I haven't looked at the gory details of subseq and rsubseq provide efficient bounded searching. I don't see the need for find or seek as that is really just (first (subseq sm)) For your particular problem (find closest) a combination of first subseq = and first rsubseq = will find you the two best candidates on either side, and thus which is closest. However this is slightly more work than if you could just do one efficient search and then access the key to the other side of the test... which is a different proposition all together than bounded search but if it is useful sounds easy enough to expose. Currently you can access the tree itself (.tree sm) works, but you can't find out what's to the left or right because those are private. Do you want to navigate the tree, or would a left and right search suffice? Regards, Tim. -- 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: Google-collections
AFAIK, Clojure's persistent data structures resolve many of the scenarios where immutability is desired. Scenario in which I think immutability is highly desired are as follows: *Scenario 1*: Non-concurrency related reason. One of the non-concurrency related reason for immutability (I dont recall of others) is to get the deep const/final effect on Objects. Clojure, being functional, return values are always copied as far as the user is concerned. So we get this const effect for free. *Scenario 2:* Concurrency related reason. Clojure's persistent data structures are AFAIK, mainly intended to solve the concurrency related reasons for desiring immutability and this issue is solved better by persistent data structures than Immutable collections. So, I think, Google's Immutable collections would be useful only for Scenario 1, if only there is a huge performance difference in the initial population of the data structure. I don't really see how that can be more perfomant, except for the reason that it is possible to achieve Worst-case O(1) access timings on Hash tables rather than Average case O(1) when the set of all possible key values is totally known before-hand and not subject to change. Thanks, Ajay On Thu, Dec 31, 2009 at 12:41 AM, Vagif Verdi vagif.ve...@gmail.com wrote: I wonder if just released http://code.google.com/p/google-collections/ google-collections java library could be of any use to clojure implementation ? They have there High-performance immutable implementations of the standard collection types and many other goodies. -- 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.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en