binary structures/bitstrings
Does anyone know of a clojure library for handling (un)packing of binary structures? I'm looking for something similar to perl/ruby/ python's pack(...) function or something like OCaml's bitstring module. My initial google and clojure-contrib perusing hasn't turned up anything obvious though I've found at least one interesting blog post on a related subject. If there is such a thing in existence I'd like to know about it otherwise I'll probably want to create it - to scratch my own itch - and maybe someone else will have an interest in such a thing. -stt -- 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
database management: curing lock issues
Question on best practices on handling SQL database concurrency issues I am pmapping a evaluation to a long list (which calls a computationally intense script) from within clojure. The script itself is designed to be completely free of concurrency side-effects. During the evaluation, several calculations are made that are then written to a SQLite database. My approach is to test for concurrency issues on a dual core system prior to moving to a cluster. What I find is that on occasion there is a database locking issue when sub-processes try to write to the database at the same time (java.sql.SQLException: database is locked). The side effect is that one of the evaluations is not written to the database (bad, cause it takes 3min to compute). I can fix it by catching the exception, and then calling (Thread/sleep) before trying to rewrite again. This is an ugly fix, and I am concerned that this may not scale properly. What is the best practices to handle such an issue in a concurrent and scalable way? Is it as simple as moving to a better database, such as mySQL? I could use Threads/Locks and move the db transaction outside the evaluation loop, or save all transactions and then commit after all evaluations are done. I can't help but feel both solns seem like cheating when working with a conncurrent language such as clojure. Any Advice? I am using contrib.sql and java.sql (org.sqlite.JDBC) -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: database management: curing lock issues
id prefer best practices if possible typically, cheating has consequences down the line On Mar 25, 10:43 am, Joop Kiefte iko...@gmail.com wrote: Isn't programming not all about cheating the computer in doing what you want it to do? In the book programming clojure you can find an example with locks as well. 2010/3/25 Scott sbuck...@gmail.com Question on best practices on handling SQL database concurrency issues I am pmapping a evaluation to a long list (which calls a computationally intense script) from within clojure. The script itself is designed to be completely free of concurrency side-effects. During the evaluation, several calculations are made that are then written to a SQLite database. My approach is to test for concurrency issues on a dual core system prior to moving to a cluster. What I find is that on occasion there is a database locking issue when sub-processes try to write to the database at the same time (java.sql.SQLException: database is locked). The side effect is that one of the evaluations is not written to the database (bad, cause it takes 3min to compute). I can fix it by catching the exception, and then calling (Thread/sleep) before trying to rewrite again. This is an ugly fix, and I am concerned that this may not scale properly. What is the best practices to handle such an issue in a concurrent and scalable way? Is it as simple as moving to a better database, such as mySQL? I could use Threads/Locks and move the db transaction outside the evaluation loop, or save all transactions and then commit after all evaluations are done. I can't help but feel both solns seem like cheating when working with a conncurrent language such as clojure. Any Advice? I am using contrib.sql and java.sql (org.sqlite.JDBC) -- 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 To unsubscribe from this group, send email to clojure+ unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: database management: curing lock issues
thanks for your suggestions two clear options 1) agents and queued transactions 2) MVC enabled databases (postgresql, h2 (neat project)) Ill try the first option and see how it scales, and worst case move to the second Thanks again Scott On Mar 25, 12:47 pm, prhlava prhl...@googlemail.com wrote: Is it as simple as moving to a better database, such as mySQL? PostgreSQL is considerably better (even than MySQL, which still uses locks AFAIK) for anything concurrent. The PostgreSQL is using multiple version concurrency (MVC) approach - the same approach the clojure STM is using. The PostgreSQL might need a bit of tuning (the defaults are very conservative), but after that it usually performs very well. Make sure that you understand the PostgreSQL transactions and how they work, but usually - in default settings, the readers do not block writers, and readers always see consistent view of the data (but this view could be a bit behind in terms of time). The PostgreSQL mailing list is both, friendly and knowledgeable - speaking from experience. Kind regards, Vladimir -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: binary representation + operators
java to the rescue! Thanks to all for your suggestions Scott On Mar 13, 3:45 pm, Michał Marczyk michal.marc...@gmail.com wrote: On 12 March 2010 23:26, Scott sbuck...@gmail.com wrote: How do I write a function 'bit' that converts an integer to binary representation: (bit 0) - 2r0 (bit 1) - 2r1 (bit 2) - 2r10 (bit 3) - 2r11 I understand that you want a way to obtain a string representation of a number in binary. I think you need to dispatch on class: (Integer/toBinaryString (int 5)) ; = 101 (Integer/toBinaryString (Integer. 5)) = 101 (Long/toBinaryString (long 5)) ; = 101 (Long/toBinaryString (Long. (long 5))) ; = 101 (.toString (bigint 5) 2) ; the 2 indicates the radix; = 101 (.toString (BigInteger. 5) 2) ; = 101 As far as I can tell, you can't use the int/long method with bigints or the other way around. If you'd like to add the 2r in front, just use str: (str 2r 101) ; = 2r101 As well, as function 'bit-concat' with the following behavior: (bit-concat 2r1 2r00) - 2r100 (bit-concat 2r0 2r00) - 2r000 (bit-concat 2r011 2r1100) - 2r000 I'd prefer to have bit-concat operate on actual numbers, not on strings; you can convert the result later. To that end, here's a possible solution (I'm *sure* there must be a better way... but it works): (let [ls (zipmap (map #(loop [n % r 1] (if (zero? n) r (recur (dec n) (* 2 r (range 0 128)) (map inc (range 0 128)))] (defn bit-length [n] (if (zero? n) 0 (condp = (class n) Integer(ls (Integer/highestOneBit n)) Long (ls (Long/highestOneBit n)) BigInteger (.bitLength n) (comment ; this returns true (every? #(== (bit-length %) (.bitLength %)) (map bigint (range 0 1000 (defn bit-concat [n m] (bit-or (bit-shift-left n (bit-length m)) m)) This will work as expected unless you use unboxed ints: user (bit-shift-left (int 1) 63) -2147483648 user (bit-shift-left (Integer. 1) 63) 9223372036854775808 user (bit-shift-left (long 1) 128) 340282366920938463463374607431768211456 user (bit-shift-left (long 1) 200) 1606938044258990275541962092341162602522202993782792835301376 user (class (bit-shift-left (long 1) 200)) java.math.BigInteger Sincerely, Michał -- 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
binary representation + operators
Two questions How do I write a function 'bit' that converts an integer to binary representation: (bit 0) - 2r0 (bit 1) - 2r1 (bit 2) - 2r10 (bit 3) - 2r11 . . . As well, as function 'bit-concat' with the following behavior: (bit-concat 2r1 2r00) - 2r100 (bit-concat 2r0 2r00) - 2r000 (bit-concat 2r011 2r1100) - 2r000 . . . I looked into formats, but everything defaults to integer representation. I need to stay in binary representation. Its for a genetic algorithm with grey coding. Thanks! Scott -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
performance improvments for the following code
wondering if I can please get some advice on how to improve the performance of this piece of code (defn select-n-tournament [popu fit-fn n] (let [k 7] (take n (repeatedly #(first (sort-by fit-fn (take k (shuffle popu)) ) ) The profiler is telling me that first is eating up alot of time. The code applies a fitness evaluation to a population of possible solutions, sorts and take n of the fittest individuls (its for an evolutionary strategy). For example, how could I utilize map and still mantain the best individual (not its actual fitness value). thanks -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
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: function to perform operations on adjacent values
Thanks! On Jan 21, 7:07 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Jan 20, 8:03 pm, Scott sbuck...@gmail.com 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
stripping parenthesis
i am utilizing parenthesis to represent a tree structure within a genetic algorithm I am trying to write a function that can strip all parenthesis such that I can perform crossovers/mutations on the permutation. Ex. ( 1 2 3 4 (5 6 7 8) ((9 10 11 12)) (((13 14 15 16))) ) into ( 1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 ) the numbers are unique and can be in any order, and parenthesis can occur anywhere in the representation [ another possible representation is ( (5 6 7 8) 1 2 3 4 (((13 14 15 16))) ((9 10 11 12)) ) -- in this case an operator must order the representation before applying the removal of parenthesis] so far I hacked something like: (use 'clojure.contrib.str-utils) (defn genome-to-list [mytree] (apply list (re-gsub #[()]* (str mytree) ) ) but I am sure there is a better option via regression, any ideas? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: stripping parenthesis
gotta love well thought out libraries Thanks Laurent one more question, what if one was to attempt the reverse, ie: ( 1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 ) into ( 1 2 3 4 (5 6 7 8) ((9 10 11 12)) (((13 14 15 16))) ) thanks, sorry just getting started with clojure/lisp On Jan 19, 11:51 am, Laurent PETIT laurent.pe...@gmail.com wrote: Maybe you're in quest ofhttp://richhickey.github.com/clojure-contrib/seq-utils-api.html#cloju... ? HTH, -- Laurent 2010/1/19 Scott sbuck...@gmail.com: i am utilizing parenthesis to represent a tree structure within a genetic algorithm I am trying to write a function that can strip all parenthesis such that I can perform crossovers/mutations on the permutation. Ex. ( 1 2 3 4 (5 6 7 8) ((9 10 11 12)) (((13 14 15 16))) ) into ( 1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 ) the numbers are unique and can be in any order, and parenthesis can occur anywhere in the representation [ another possible representation is ( (5 6 7 8) 1 2 3 4 (((13 14 15 16))) ((9 10 11 12)) ) -- in this case an operator must order the representation before applying the removal of parenthesis] so far I hacked something like: (use 'clojure.contrib.str-utils) (defn genome-to-list [mytree] (apply list (re-gsub #[()]* (str mytree) ) ) but I am sure there is a better option via regression, any ideas? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: stripping parenthesis
thanks all! On Jan 19, 2:06 pm, kyle smith the1physic...@gmail.com wrote: http://groups.google.com/group/clojure/browse_thread/thread/806ebb1cb... -- 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: Cond, and abusing or
On Jan 15, 2:02 pm, Simon Brooke still...@googlemail.com wrote: There's an old programmers hack that works in many languages of abusing the logical or operator to try a sequence of operations until one returns something useful. It appears that this works in Clojure, too. Certainly, this is a very common idiom in Common Lisp and other older dialects. I guess there are a few people who don't like it, but a lot of us do it routinely. You'll even see stuff like (or (try-to-construct-a-foo) (error Couldn't construct a foo)) -- Scott -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
[ANN] units.clj - unit conversion functions without repeating yourself
Hi, I created a library that provides unit conversion functions[1] for several common units and allows you to define new units conversions with a single equation. The library does a few interesting things automatically: First, if you define inches-to-feet, it will create feet-to-inches for you. Second, if you define inches-to-feet and feet-to-meters, it will create inches-to-meters and meters-to-inches for you. Third, it will create the equivalent square and cubic functions as well. So for inches, feet, yards, meters, centimeters, millimeters, miles, and kilometers, if you specify 7 equations this library will define 168 conversion functions for you (56 each for length, area, and volume). The code is at http://gist.github.com/276662#file_units.clj I'd love to receive feedback. Thanks, Scott Notes [1] For a reliable alternative, see JScience.org -- 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: globing filenames via clojure
Thanks Travis this was exactly what I was looking for: (import '(java.io File)) (first (filter #(re-matches #.*\.txt %) (.list (File. ./) ))) I am using the csv parser from : http://github.com/davidsantiago/clojure-csv I would enjoy seeing your implementation On Dec 13, 2:19 am, Travis twell...@gmail.com wrote: On Dec 12, 11:20 am, Scott sbuck...@gmail.com wrote: Trying to learn clojure via some simple examples. I would like to use a simple glob expression to open a file using read- line How would I write the equivalent of: (for [line (read-lines *.txt)] (print line)) Where *.txt would match only the first file found in the present working directory I haven't tried executing these, but maybe something like this: (slurp (first (filter #(re-matches #.*\.txt %) (.list (File. directory/path) Or, more verbose but using Java's standard FilenameFilter (slurp (first (.list (File. directory/path) (proxy [FilenameFilter] [] (accept [fil nam] (if (re-matches #.*\.txt nam) true false)) what I am actually trying to write is a program to read in a CSV, apply to a hash-map, and extract some simple data, so the above is intentional simplification very powerful language, thanks to all that have worked on this I have a function for parsing CSVs that I put to work a lot at my last job, using the Ostermiller utils. It works for very large CSVs and is fairly thoroughly tried. Send me an email directly if you're stuck on that. -- 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
globing filenames via clojure
Trying to learn clojure via some simple examples. I would like to use a simple glob expression to open a file using read- line How would I write the equivalent of: (for [line (read-lines *.txt)] (print line)) Where *.txt would match only the first file found in the present working directory what I am actually trying to write is a program to read in a CSV, apply to a hash-map, and extract some simple data, so the above is intentional simplification very powerful language, thanks to all that have worked on this -- 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: temp variables best practice
Terrance, you could do something like this (loose on the syntax): (def final-foo (let [tmpString (. javax.swing.JOptionPane showInputDialog What is your foobar?)] (. Double parseDouble tmpString))) Look at this comment for one example of a function written both ways: http://lojic.com/blog/2009/03/01/digest-tag-population-in-ruby/comment-page-1/#comment-1879 -- Scott On Sat, Sep 12, 2009 at 7:23 PM, Terrance Davis terrance.da...@gmail.comwrote: For instance, in Java ... tmpString = JOptionPane.showInputDialog(What is your foobar?); finalFoo = Double.parseDouble(tmpString); instead of ... finalFoo = Double.parseDouble(JOptionPane.showInputDialog(What is your foobar?)); I translate this into Clojure as something like ... (def final-foo (. Double parseDouble (. javax.swing.JOptionPane showInputDialog What is your foobar?))) Obviously this a contrived example, and I didn't compile it to make sure it works. Still, you can easily imagine more complex code having many more levels of indentation. How would I break up the Clojure version in a Clojure-esque manner? On Sat, Sep 12, 2009 at 4:42 PM, Sean Devlin francoisdev...@gmail.com wrote: Could you post an example? It'd be easier to comment on it. On Sep 12, 6:32 pm, Terrance Davis terrance.da...@gmail.com wrote: Commonly, I break down complex lines of code into several easy to follow simple lines of code. This results in many temp variables that are not intended to be used anywhere else in the code. Sometimes I see a method reusing common primitives and objects (like ints and Strings), so to prevent verbosity (meaning many unnecessary variable definitions), I define variables named something like 'tmpString' or 'tmpInt' with a local scope and reuse them locally. This is all to prevent verbose hard to read code. I can read through the simplified code ignoring variables with the visual tag of 'tmp'. I also benefit from the simpler code that does not chain several commands in one line. What is the best practice in Clojure? How do I properly break down chained commands? Am I completely missing the zen of FP? ;-) -- http://scott.andstuff.org/ | http://truthadorned.org/ --~--~-~--~~~---~--~~ 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 quickstart maven archetype
When I said central repo, yes, I meant repo1.maven.org. Clojure contrib is only available as a SNAPSHOT there. My actual dependency element looks like: dependency groupIdorg.clojure/groupId artifactIdclojure-contrib/artifactId version1.0-SNAPSHOT/version /dependency -Scott On Sep 9, 12:42 am, Fredrik Appelberg fredrik.appelb...@gmail.com wrote: On Tue, Sep 8, 2009 at 4:09 AM, Scott Fleckenstein nullst...@gmail.comwrote: On another note, it's surprising given that how easy creating the archetype was how incredibly arcane writing a plugin is. Granted, maven is new to me and I've got zero experience but the codebase, but it seems amazing to me how complicated doing something as small as launching a repl process can be. I must have gone through 20,000 lines of various peoples code today to try and attempt building one myself, from your plugin (which, was the nicest so far, BTW) to antrun, to the exec plugin, to the clojureshell plugin. It's quite comical considering the 8 line rake file I've got to do it. Oh well, I'll figure it out eventually. Agreed. The process of writing a maven plugin is really a lot more complicated than it ought to be. When I started on Clojureshell I couldn't really find any relevant javadocs anywhere and had to go through a lot of trial and error before I got classloading working. And running clojure inside the maven process wasn't really a serious design decision; it just seemed a lot easier than spawning a child process ;) BTW, you mentioned the official maven clojure repo, is that repo1.maven.orgor somewhere else? I can find clojure-1.0.0 there, but not clojure-contrib. Cheers, -- Fredrik == What am I up to?http://twitter.com/appelberg --~--~-~--~~~---~--~~ 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 quickstart maven archetype
Thanks Stuart, Just an FYI, I added repl support to the clojure-maven-plugin here: http://github.com/nullstyle/clojure-maven-plugin/tree/master Rather than taking clojureshell's approach, I start a separate process similar to how the rest of the plugin works. In fact, I just needed to refactory the abstract mojo used so that it can support an interactive child process, and it came together super simply. I think it is a much more understandable approach than running clojure inside the maven process, but that's just IMO. Next on my list is to add jline support onto the archetype, and figure out how best I want to support AOT along with Script execution. -Scott On Sep 7, 9:40 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote: Also look at the ClojureShell Maven plugin,http://github.com/fred-o/clojureshell-maven-plugin/tree/master which runs a REPL or Swank server. -SS On Sep 7, 10:41 pm, Mark Derricutt m...@talios.com wrote: Most definitely - I did have a repl goal for awhile but had issues with the input/output streams. Looking at my github forkqueue I see someones pulled it back out (or added a new one, I've not yet had a look at it) which might be a starting point for you... But by all means - patches galore are welcome ;) -- Pull me down under... Sent from Auckland, Auk, New Zealand On Tue, Sep 8, 2009 at 2:09 PM, Scott Fleckenstein nullst...@gmail.comwrote: If I'm able to get a repl goal working, are you open to patches? --~--~-~--~~~---~--~~ 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] Clojure quickstart maven archetype
URL: http://github.com/nullstyle/clojure-quickstart/tree/master Hi all, As a little weekend project and something to spur me to start learning maven, I put together a simple little clojure quickstart archetype. It sets you up a hello world command line application from which you can build out something real. Other notes: - Uses clojure 1.0 and clojure-contrib 1.0-SNAPSHOT from the central maven repo - Uses clojure-maven-plugin 1.0 from the central maven repo - Configured for testing support - Uses appassembler and assembly plugin to build a launcher script and package a distribution archive. After mvn package you'll have - distribution archives that are suitable for, you guessed it, distribution :p This was thrown together over a couple of late hours last night, so any questions, comments, criticisms would be greatly appreciated. Some known issues are that there's not an easy way to launch a REPL into your code, and no support fr clojure-maven-plugin clojure:run (it uses a script, my archetype assumes a compiled main class). Thanks, Scott Fleckenstein --~--~-~--~~~---~--~~ 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 quickstart maven archetype
One of the things that I'm not happy with my archetype with right now (I'm working on it at the moment) is that there isn't an way to support both AOT compilation as well as directly running the script that feels right. Everything I've thought about seems overwrought. Adding support for specifying a compiled class in the run goal would be nice, but I think I actually need to change up my archetype so the clojure file that gets compiled to the main class is just a stub that runs a different file to actually perform the work. That will mean we can support both cases pretty simply. On another note, it's surprising given that how easy creating the archetype was how incredibly arcane writing a plugin is. Granted, maven is new to me and I've got zero experience but the codebase, but it seems amazing to me how complicated doing something as small as launching a repl process can be. I must have gone through 20,000 lines of various peoples code today to try and attempt building one myself, from your plugin (which, was the nicest so far, BTW) to antrun, to the exec plugin, to the clojureshell plugin. It's quite comical considering the 8 line rake file I've got to do it. Oh well, I'll figure it out eventually. If I'm able to get a repl goal working, are you open to patches? -Scott On Sep 7, 5:58 pm, Mark Derricutt m...@talios.com wrote: Excellent! This was one of the missing pieces I was hoping to pull together next. into your code, and no support fr clojure-maven-plugin clojure:run (it I could change this to check if you mention a .clj or just a class name, and run either-or. Theres also thehttp://mojo.codehaus.org/exec-maven-plugin/plugin if you want to depend on mojo. -- On Tue, Sep 8, 2009 at 6:37 AM, Scott Fleckenstein nullst...@gmail.comwrote: URL: http://github.com/nullstyle/clojure-quickstart/tree/master Hi all, As a little weekend project and something to spur me to start learning maven, I put together a simple little clojure quickstart archetype. It sets you up a hello world command line application from which you can build out something real. Other notes: - Uses clojure 1.0 and clojure-contrib 1.0-SNAPSHOT from the central maven repo - Uses clojure-maven-plugin 1.0 from the central maven repo - Configured for testing support - Uses appassembler and assembly plugin to build a launcher script and package a distribution archive. After mvn package you'll have - distribution archives that are suitable for, you guessed it, distribution :p This was thrown together over a couple of late hours last night, so any questions, comments, criticisms would be greatly appreciated. Some known issues are that there's not an easy way to launch a REPL into your code, and no support fr clojure-maven-plugin clojure:run (it uses a script, my archetype assumes a compiled main class). Thanks, Scott Fleckenstein --~--~-~--~~~---~--~~ 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: Request for Discussion: user created reader macros
On Aug 13, 1:30 pm, Brian Hurt bhur...@gmail.com wrote: I'm just wondering what people's response would be to allow user-generated reader macros. [...] I think you could get most of the benefits for DSL's by using regular strings, except that regular strings have quoting issues: (my-dsl-macro Here is my string, but I have to escape \ characters, which is unpleasant) A single super quoted string reader would avoid this problem. Instead of defining a new read syntax like: #my-syntax(your DSL goes between here and here) Clojure could provide a general purpose string creating read syntax. Something like #... (my-dsl-macro #///Here is a specially quoted string, and I can put anything besides three slashes in it///) (my-dsl-macro #--- In this case, I can type anything except three dashes---) (pretend-this-one-is-apl #///X[⍋X+.≠' ';]///) They're just plain old macros, so namespaces would be resolve as they do now. Just a thought... --~--~-~--~~~---~--~~ 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: Request for Discussion: user created reader macros
On Aug 13, 5:47 pm, Chas Emerick cemer...@snowtide.com wrote: A good thought, but #foo is reader syntax for defining a regular expression with the pattern foo. :-/ Sorry about that, I'm not experienced at Clojure, but I should have been more clear. The first important part isn't which character triggers the arbitrary string literal (as you point out, # is already taken), but that you get to choose the terminating delimiter such that it doesn't interfere with your DSL. The second part is that once you can cleanly express arbitrary string literals, a regular macro can substitute for a reader macro and avoids the namespace issues. Double-quoted strings are decent for stuff like this. (Triple-quotes in python always appealed to me, though triple-quoting things can get tiring.) I use Python's triple quotes too, but you may want to create a DSL that can contain both ''' (triple single quote) and (triple double quote) in it. (For instance if you were embedding Python source. :-) --~--~-~--~~~---~--~~ 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: PeepCode screencast
Thanks Phil! I just bought it and look forward to watching it this weekend. Are you planning something more advanced? On Fri, Apr 24, 2009 at 11:03 AM, Phil Hagelberg p...@hagelb.org wrote: I'm proud to announce that the Functional Programming with Clojure PeepCode screencast has just been published: http://peepcode.com/products/functional-programming-with-clojure It's a professionally-produced 65-minute video that introduces all the foundational concepts of Clojure by stepping through the creation of a multiplayer text adventure game. If you've been looking for a quick way to get up to speed on Clojure, this is your ticket. The screencast is sold for $9, and there's a preview available: http://peepcode.com/system/uploads/2009/peepcode-clojure-preview.mov Hope you like it! -Phil Hagelberg http://technomancy.us --~--~-~--~~~---~--~~ 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 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: Java 6 dependency in clojure-contrib ok?
I would strongly recommend Java 5 and plan on staying with that version for a while if you have a goal seeing corporate uptake for Clojure. The Java version debate comes up every few months on the Groovy lists. The most common argument I've heard was that any company progressive enough to use a language like Groovy or Clojure would be using current versions of Java so there is no harm in using the current version of Java. My experience consulting for medium and large companies is that this is a false assumption. Most companies are years behind the current Java version but are still open to using new technologies that will run on their current platforms. The web app servers that get deployed usually lag way behind Java releases and converting legacy Java apps to newer versions of Java + app servers is a major project for many companies. They put it off for as long as possible. It may not make sense to those of us trying new languages on the JVM but it is a reality that is out there. Scott Hickey Senior Consultant Object Partners, Inc. From: Rich Hickey richhic...@gmail.com To: Clojure clojure@googlegroups.com Sent: Wednesday, April 8, 2009 7:31:19 PM Subject: Re: Java 6 dependency in clojure-contrib ok? On Apr 8, 7:52 pm, Stuart Halloway stuart.hallo...@gmail.com wrote: Perry's proposed props functions (http://groups.google.com/group/clojure/browse_thread/thread/c8ec751b8... ) uses some Java 6 methods. Is it ok for me to add such things to contrib, or are we maintaining Java 5 compatibility? I'd prefer we maintain Java 5 for now. 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 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: Parallel Game of Life
I have not had a chance to merge the parallel updates in to life- conway.clj in the files section yet, but for now I thought I would note I did make one fun enhancement, which is to have each thread color code the cells. So all cells with the same color were processed by one pmap thread. On my 8-core it is quite colorful and fun. As always, comments appreciate. Here is it: -Scott (import '(javax.swing JFrame JPanel JButton) '(java.awt BorderLayout Dimension Color) '(java.awt.event ActionListener)) (def cells (ref {})) (def running (atom false)) (def x-cells ( * 32 1)) (def y-cells ( * 48 1)) ;(def x-cells 32) ;(def y-cells 32) (def range-cells (for [x (range x-cells) y (range y-cells)] [x y])) (def length-range-cells (count range-cells)) (def cell-size 10) (def life-delay 0) (def life-initial-prob 3) (def available-procs (.. java.lang.Runtime getRuntime availableProcessors)) ;(def available-procs 8) (def batch-sets (for [cpu (range available-procs)] (take-nth available- procs (drop cpu range-cells ; some things we will use to give each thread a different color (def counter (ref 0)) (def color-list [Color/RED Color/ORANGE Color/GREEN Color/YELLOW Color/ BLUE Color/MAGENTA Color/PINK Color/CYAN]) (def num-colors (count color-list)) (def empty-color Color/BLACK) (defn next-color [] (dosync (if (or (= @counter (dec num-colors)) (= @counter (dec available-procs))) (ref-set counter 0) (alter counter inc (defn determine-initial-state [x y] (= 0 (rand-int life-initial-prob))) (defn determine-new-state [x y] (let [alive (count (for [dx [-1 0 1] dy [-1 0 1] :when (and (not (= 0 dx dy)) (not (= empty-color (cells [ (mod (+ x dx) x-cells) (mod (+ y dy) y-cells)]] :alive))] (if (not (= (cells [x y]) empty-color)) ( 1 alive 4) (= alive 3 (defn update-batch-of-new-cells [new-cells list-of-batches] (dosync (dorun (map #(commute new-cells assoc (first %) (second %)) list-of-batches)) )) (defn calc-batch-of-new-cell-states [cell-state batch-cells] ( let [thread-color (nth color-list (next-color))] doall (map #(let [new-cell-state (if (cell-state (first %) (second %)) thread-color empty-color)] [[(first %) (second %)] new-cell-state]) batch-cells))) (defn calc-state [cell-state] (let [new-cells (ref {})] (dorun (pmap #(update-batch-of-new-cells new-cells %) (pmap #(calc-batch-of-new-cell-states cell-state %) batch-sets))) (dosync (ref-set cells @new-cells (defn paint-cells [#^java.awt.Graphics graphics] (doseq [[[x,y] state] @cells] (doto graphics (.setColor state) (.fillRect (* cell-size x) (* cell-size y) cell-size cell- size (defn toggle-thread [#^JPanel panel button] (if @running (do (dosync (reset! running false)) (. button (setText Start))) (do (dosync (reset! running true)) (. button (setText Stop)) (. (Thread. #(loop [] (calc-state determine-new-state) (.repaint panel) (if life-delay (Thread/sleep life-delay)) (if @running (recur start (defn -main[] (calc-state determine-initial-state) (let [f (JFrame.) b (JButton. Start) panel (proxy [JPanel] [] (paint [graphics] (paint-cells graphics)))] (doto f (.setLayout (BorderLayout.)) (.setLocation 100 100) (.setPreferredSize (Dimension. (* cell-size x-cells) (+ 60 (* cell-size y-cells (.add b BorderLayout/SOUTH) (.add panel BorderLayout/CENTER) (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE) (.pack) (.setVisible true)) (. b addActionListener (proxy [ActionListener] [] (actionPerformed [evt] (toggle-thread panel b)) On Mar 16, 11:51 am, Larry Sherrill lps...@gmail.com wrote: Hi Kyle, I added life-conway.clj to the files section last week. It has rand, clear, and bounded buttons, and the ability to use your mouse to draw the pattern rather than rely on rand. It's a good way to experiment with different automata such as gliders. Larry Sherrill On Mar 16, 9:33 am, Kyle R. Burton kyle.bur...@gmail.com wrote: On Mon, Mar 16, 2009 at 12:31 AM, Scott Fraser scott.e.fra...@gmail.com wrote: I have taken Larry's Game of Life example that he originally posted here: http://groups.google.com/group/clojure/msg/fdfc88f1ba95bdee ...and updated it to use all the CPU's your JVM has access to... Scott, Your changes indeed make it run significantly faster for me. Thanks! I added a 'reset' button and changed some of the java method calls to be a bit more (I think) idomatic clojure. The full file is here:http://asymmetrical-view.com/personal/code/clojure/life.clj And a patch is attached (you also left off the import statements in you email
Re: Parallel Game of Life
Larry, that you added mouse-drawing is awesome, I wanted to do that too. Kyle - my bad on the imports, thanks for the patch. I will take all these and refold in when I get some time. I also have some ideas on further speed ups. My gut tells me we could make this run faster. One other idea - add a throttle for the available-procs value, and a real time Frames Per Second display. It would be interesting to figure out on various hardware what is the right setting for available- procs, which currently in this version is really more related to the size and number of the chunks of work as opposed to how many threads actually get deployed behind the scenes by pmap. Note that based on my profiling, if I have 8 CPU's available, and I throw out there 8 chunks of work, pmap is using a pool of 8 or so threads behind the scenes to process the work. Would be good to understand how pmap sizes that executor pool. -Scott On Mar 16, 11:51 am, Larry Sherrill lps...@gmail.com wrote: Hi Kyle, I added life-conway.clj to the files section last week. It has rand, clear, and bounded buttons, and the ability to use your mouse to draw the pattern rather than rely on rand. It's a good way to experiment with different automata such as gliders. Larry Sherrill On Mar 16, 9:33 am, Kyle R. Burton kyle.bur...@gmail.com wrote: On Mon, Mar 16, 2009 at 12:31 AM, Scott Fraser scott.e.fra...@gmail.com wrote: I have taken Larry's Game of Life example that he originally posted here: http://groups.google.com/group/clojure/msg/fdfc88f1ba95bdee ...and updated it to use all the CPU's your JVM has access to... Scott, Your changes indeed make it run significantly faster for me. Thanks! I added a 'reset' button and changed some of the java method calls to be a bit more (I think) idomatic clojure. The full file is here:http://asymmetrical-view.com/personal/code/clojure/life.clj And a patch is attached (you also left off the import statements in you email). FYI: Scott Fraser is giving a talk on clojure at the Philly Emerging Technologies for the Enterprise conference next week: http://phillyemergingtech.com/abstractsTab.php?sessID=39 http://phillyemergingtech.com/speakers.php Regards, Kyle Burton -- --- --- kyle.bur...@gmail.com http://asymmetrical-view.com/ --- --- life.patch 3KViewDownload --~--~-~--~~~---~--~~ 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 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: Game of Life
Hi Larry I have a performance tweak, that gives about an order of magnitude speedup to paint-cells when running this with a large grid and no or little (Thread/sleep life-delay) in toggle-thread. That is how I am running it now - 128 x 192 cells with no delay! It is also noticeably faster on the more typical size grid. Type hint is on the graphics param: (defn paint-cells [#^java.awt.Graphics graphics] (time (doseq [[[x,y] state] @cells] (doto graphics (. setColor (if state Color/RED Color/WHITE)) (. fillRect (* cell-size x) (* cell-size y) cell-size cell- size) Example, with type hint: Elapsed time: 45.871193 msecs Elapsed time: 39.209662 msecs Elapsed time: 43.899504 msecs Without: Elapsed time: 529.635331 msecs Elapsed time: 438.145769 msecs Elapsed time: 442.839872 msecs I would imagine there may be some other way to get clojure to cache the reflected handle to Graphics, but I am still a little new to this so don't have any other ideas on how to eliminate the high amount of reflection without a type hint. -Scott http://fraser.blogs.com/ On Mar 4, 4:17 pm, Larry Sherrill lps...@gmail.com wrote: I've incorporated everyone's suggestions and thought I would post the resulting smaller code. I refactored init-cells away and just pass in an init or new function to calc-state to reuse the for loop. I made determine-next-state a little more verbose than technically necessary to makeconway'srules more obvious to me. The refs cells and running don't feel very functional but I don't know how to get rid of them. (import '(javax.swing JFrame JPanel JButton) '(java.awt BorderLayout Dimension Color) '(java.awt.event ActionListener)) (def cells (ref {})) (def running (ref false)) (defn determine-initial-state [x y] (= 0 (rand-int 5))) (defn determine-new-state [x y] (let [neighbor-count (count (for [dx [-1 0 1] dy [-1 0 1] :when (and (not (= 0 dx dy)) (cells [(+ x dx) (+ y dy)]))] :alive))] (if (cells [x y]) ( 1 neighbor-count 4) (= neighbor-count 3 (defn calc-state [cell-state] (dosync (ref-set cells (reduce conj {} (for [x (range 32) y (range 48)] [[x y] (cell-state x y)]) (defn paint-cells [graphics] (doseq [[[x, y] state] @cells] (doto graphics (. setColor (if state Color/RED Color/WHITE)) (. fillRect (* 10 x) (* 10 y) 10 10 (defn toggle-thread [panel button] (if @running (do (dosync (ref-set running false)) (. button (setText Start))) (do (dosync (ref-set running true)) (. button (setText Stop)) (. (Thread. #(loop [] (calc-state determine-new-state) (. panel repaint) (Thread/sleep 100) (if @running (recur start (defn main[] (calc-state determine-initial-state) (let [f (JFrame.) b (JButton. Start) panel (proxy [JPanel] [] (paint [graphics] (paint-cells graphics)))] (doto f (. setLayout (BorderLayout.)) (. setLocation 100 100) (. setPreferredSize (Dimension. 320 540)) (. add b BorderLayout/SOUTH) (. add panel BorderLayout/CENTER) (. setDefaultCloseOperation JFrame/EXIT_ON_CLOSE) (. pack) (. setVisible true)) (. b addActionListener (proxy [ActionListener] [] (actionPerformed [evt] (toggle-thread panel b)) (main) Thanks for everyone. Very good learning experience. Larryhttp://lpsherrill.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 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 Game of Life
I have taken Larry's Game of Life example that he originally posted here: http://groups.google.com/group/clojure/msg/fdfc88f1ba95bdee ...and updated it to use all the CPU's your JVM has access to. My first attempts ran into the classic map - pmap slowdown. My next attempt had too much dosync, in that there were many threads but they were all waiting for each other. I finally rewrote the calc-state routine to batch the units of work into meaty sizes, and to minimize the dosync granularity. It gets the batches of new-state together, then goes and applies these in batches. In both events I use pmap. Now it is running really fast on my 4-core Intel i7. You will really notice a difference at larger grid sizes. On my i7 it keeps the 8 (due to hyperthreading) cpus busy at about 60% when I run a huge grid. I also updated paint-cells with a type hint that greatly reduces reflection in that performance critical code. I am very new to clojure and would appreciate feedback. I am concerned I may have overcomplicated things with my usage of the map/pmap form. I am guessing there may be a simpler way to write what I did. Note at the start it will automatically select how many available- procs you have. Try tweaking this on your hardware to see how it impacts performance. Watching the threads with a profiler is interesting. Here is is: (def cells (ref {})) (def running (ref false)) ;(def x-cells ( * 32 4)) ;(def y-cells ( * 48 4)) (def x-cells 32) (def y-cells 32) (def range-cells (for [x (range x-cells) y (range y-cells)] [x y])) (def length-range-cells (count range-cells)) (def cell-size 10) (def life-delay 0) (def life-initial-prob 3) (def available-procs (.. java.lang.Runtime getRuntime availableProcessors)) (defn determine-initial-state [x y] (= 0 (rand-int life-initial-prob))) (defn determine-new-state [x y] (let [alive (count (for [dx [-1 0 1] dy [-1 0 1] :when (and (not (= 0 dx dy)) (cells [ (mod (+ x dx) x-cells) (mod (+ y dy) y-cells)]))] :alive))] (if (cells [x y]) ( 1 alive 4) (= alive 3 (defn update-batch-of-new-cells [new-cells list-of-batches] (dosync (dorun (map #(commute new-cells assoc (first %) (second %)) list-of-batches)) )) (defn calc-batch-of-new-cell-states [cell-state batch-cells] (doall (map #(let [new-cell-state (cell-state (first %) (second %))] [[(first %) (second %)] new-cell-state]) batch-cells))) (defn calc-state [cell-state] (let [new-cells (ref {})] (dorun (pmap #(update-batch-of-new-cells new-cells %) (pmap #(calc-batch-of-new-cell-states cell-state %) (for [cpu (range available-procs)] (take-nth available- procs (drop cpu range-cells)) (dosync (ref-set cells @new-cells (defn paint-cells [#^java.awt.Graphics graphics] (doseq [[[x,y] state] @cells] (doto graphics (. setColor (if state Color/RED Color/WHITE)) (. fillRect (* cell-size x) (* cell-size y) cell-size cell- size (defn toggle-thread [#^JPanel panel button] (if @running (do (dosync (ref-set running false)) (. button (setText Start))) (do (dosync (ref-set running true)) (. button (setText Stop)) (. (Thread. #(loop [] (calc-state determine-new-state) (. panel repaint) (if life-delay (Thread/sleep life-delay)) (if @running (recur start (defn -main[] (calc-state determine-initial-state) (let [f (JFrame.) b (JButton. Start) panel (proxy [JPanel] [] (paint [graphics] (paint-cells graphics)))] (doto f (. setLayout (BorderLayout.)) (. setLocation 100 100) (. setPreferredSize (Dimension. (* cell-size x-cells) (+ 60 (* cell-size y-cells (. add b BorderLayout/SOUTH) (. add panel BorderLayout/CENTER) (. setDefaultCloseOperation JFrame/EXIT_ON_CLOSE) (. pack) (. setVisible true)) (. b addActionListener (proxy [ActionListener] [] (actionPerformed [evt] (toggle-thread panel b)) --~--~-~--~~~---~--~~ 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 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 profilers are you using?
On Sat, Feb 7, 2009 at 8:16 AM, David Powell djpow...@djpowell.net wrote: Newer versions of JDK 1.6, eg Update 11, have an application called 'jvisualvm' in the bin directory. It lets you attach to any running Java process and it has a profiler that you can switch on at runtime. If you're starting Clojure from inside Emacs under Windows then you might have trouble connecting to it with VisualVM. Start Clojure from outside emacs, connect to it using slime, and VisualVM should work fine. --~--~-~--~~~---~--~~ 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 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: Fully lazy sequences are coming - feedback wanted!
How about e-rest, for the empty set returning version? Perry Trolard wrote: If it's the case that rest will almost exclusively appear in the context of constructing lazy-seqs (lazy-seq (cons [something] (rest [something])) next will appear all over, it makes sense to me to sacrifice brevity in the case of rest, give next the right name: "rest" --~--~-~--~~~---~--~~ 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 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: semi-structured program editing
http://mumble.net/~campbell/emacs/paredit.el http://mumble.net/~campbell/emacs/paredit.html Should work out of the box with Clojure and Emacs. - Scott On Jan 2, 8:48 pm, falcon shahb...@gmail.com wrote: http://www.cs.brown.edu/research/plt/software/divascheme/ or http://www.youtube.com/watch?v=GnQV4je9wTQ Just for some inspiration :) --~--~-~--~~~---~--~~ 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 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: Microsoft SQL Server and the sql contrib
Thanks for the idea. Although those are definitely necessary steps, unfortunately the problem still persists. On Tue, Dec 16, 2008 at 5:47 PM, Wayne R johnway...@gmail.com wrote: Have a look at http://dertompson.com/2007/10/06/connection-to-mssql-server-express-2005-with-jdbc/ Apparently using JDBC with MSSQL Express requires some extra setup. On Dec 16, 3:49 pm, Scott Jaderholm jaderh...@gmail.com wrote: I don't think that's a problem: user (. Class (forName com.microsoft.sqlserver.jdbc.SQLServerDriver)) com.microsoft.sqlserver.jdbc.SQLServerDriver On Tue, Dec 16, 2008 at 12:21 PM, MikeM michael.messini...@invista.com wrote: To make sure your driver is really on the classpath, try this from the REPL: (. Class (forName com.microsoft.sqlserver.jdbc.SQLServerDriver)) --~--~-~--~~~---~--~~ 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 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: Microsoft SQL Server and the sql contrib
I don't think that's a problem: user (. Class (forName com.microsoft.sqlserver.jdbc.SQLServerDriver)) com.microsoft.sqlserver.jdbc.SQLServerDriver On Tue, Dec 16, 2008 at 12:21 PM, MikeM michael.messini...@invista.comwrote: To make sure your driver is really on the classpath, try this from the REPL: (. Class (forName com.microsoft.sqlserver.jdbc.SQLServerDriver)) --~--~-~--~~~---~--~~ 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 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: In core structure editor, anyone?
Seems like having something like this would be a good step towards supporting image-based development similar to Smalltalk. Whether that is a good thing or not is a different discussion ;) -Scott Fleckenstein On Dec 10, 8:16 am, Stuart Sierra [EMAIL PROTECTED] wrote: On Dec 10, 7:15 am, Simon Brooke [EMAIL PROTECTED] wrote: But in-core structure editors are extremely powerful and useful when editing homoiconic languages, so... is anyone working on an in-core editor for Clojure? Not that I've heard, but Emacs + Paredit http://www.emacswiki.org/cgi- bin/wiki/ParEdit is a powerful combination. Paredit is like a structured editor for Lisp expressions. There's a patch to handle Clojure data structures: http://github.com/jochu/clojure-mode/tree/ master/clojure-paredit.el -Stuart Sierra --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Unary Application of (= ...)
I'm a newbie, so feel free to bash me on the noggin if i'm missing something: Personally, I would love = to support null-ary case; being able to use apply with = seems very powerful, and would remove the need to check for an empty sequence. -Scott On Dec 3, 9:39 pm, Krukow [EMAIL PROTECTED] wrote: On Dec 4, 5:40 am, Stephen C. Gilardi [EMAIL PROTECTED] wrote: I agree. By the identity element argument, (/) should be 1 and (-) should be 0. Regarding *the* identity argument, I think it only works if the operator is associative. Otherwise, you can talk about a left identity or a right identity (if it exists). A right identity for op is an x so that for all y: y op x = y. The left identity is an x so that for all y: x op y. Clojure seems to be using the 'right' identity argument ;-) Anyway, another interpretation of '=' would be logical/set-theoretic: (= o1 o2 ... on) means: for all x,y in {o1, ... ,on} . x = y. Then (not= o1 o2 ... on) could just be (not (= o1 o2 ... on)). Then (=) would be true and (not=) would be false. Kind Regards, - Karl --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
A request for clojure code critique
So, I'm starting to get my feet wet with a real project written in Clojure. One of the first things needed in the project is a periodic process to check an external server for updates, and so I wrote some functions to help this. The code is here: http://pastie.textmate.org/private/1q0c0ydhvdjlzssc896k1w I'm new to Clojure, for that matter any Lisp, so I'm wondering what I could do better with that code. Am I doing anything blatantly wrong? Basically, there are four functions: send-after, send-off-after, send- periodically, and send-off periodically. They leverage the agent system, and mirror the send/send-off functions. The -after variants are one shot sends that wait for a specified timeout and then send, whereas the -periodically variants repeatedly send using the given interval. Thanks, Scott Fleckenstein --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
add-classpath erroring out, post r1100...
Hi All, I've run into a bug since upgrading past revision 1100, specifically around adding to the classpath at runtime using add-classpath. I've attached a test case here: http://s3.amazonaws.com/nullstyle/precompile-bug.tar.gz That file has three versions of clojure (r1100, r1101, r1106) and web.clj, a sample app that loads jetty and starts a simple web server. You can use run.sh in that same tar to run each revision, one after the other, to illustrate the breakage. Basically, after adding a jar to the classpath, when importing a class file from that jar I get a ClassNotFoundException thrown. I don't have enough java experience to know what would cause this problem. Things work as expected on revision 1100. Does anyone know what would cause this? I'd be happy to put in the time to help debug and fix this, but I'm at a loss for where next to go. Thanks, Scott Fleckenstein --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: add-classpath erroring out, post r1100...
Thanks Rich, While I understand the desire to stick with java conventions when it comes to adding to the classpath, it is too bad because it takes away from the 'explorability' you get with a Repl. I've gotten into the habit of just dumping jars into my scratch folder and tooling away on my running Repl to learn an API. Oh well, I can tweak my workflow :) -Scott On Nov 17, 10:32 am, Rich Hickey [EMAIL PROTECTED] wrote: On Nov 17, 1:00 pm, Scott Fleckenstein [EMAIL PROTECTED] wrote: Hi All, I've run into a bug since upgrading past revision 1100, specifically around adding to the classpath at runtime using add-classpath. I've attached a test case here:http://s3.amazonaws.com/nullstyle/precompile-bug.tar.gz That file has three versions of clojure (r1100, r1101, r1106) and web.clj, a sample app that loads jetty and starts a simple web server. You can use run.sh in that same tar to run each revision, one after the other, to illustrate the breakage. Basically, after adding a jar to the classpath, when importing a class file from that jar I get a ClassNotFoundException thrown. I don't have enough java experience to know what would cause this problem. Things work as expected on revision 1100. Does anyone know what would cause this? I'd be happy to put in the time to help debug and fix this, but I'm at a loss for where next to go. Such use of add-classpath is discouraged. The only reason for add- classpath is to let you pull in something if you've started up the repl without it. It shouldn't be a permanent part of any application design. In your case, you can get the local Jetty jars in the mix by supplying an extension dirs directive (-Djava.ext.dirs=) on the command line: java -Djava.ext.dirs=. -cp clojure-r1106.jar clojure.lang.Script web.clj All three revisions work with this change, and you can remove the add- classpath calls. The change that caused this is that now .class files for Clojure fn classes can be found and loaded by a classloader higher up in the chain, one which can't see the effects of add-classpath. I'm going to deprecate add-classpath because people consistently use it to avoid the standard classpath-setting mechanisms, at least until I can figure out a way to coordinate it with the standard classloader. 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Using a Java Debugger with Clojure
It should work. Before I had a debugging working in Eclipse with Groovy, I used JSwat, JEdit and Ant for project work with success. Scott Hickey Senior Consultant Object Partners, Inc. - Original Message From: Bill Clementson [EMAIL PROTECTED] To: clojure@googlegroups.com Sent: Tuesday, October 28, 2008 1:43:58 PM Subject: Re: Using a Java Debugger with Clojure Hi Peter, On Tue, Oct 28, 2008 at 11:27 AM, Peter Wolf [EMAIL PROTECTED] wrote: Hello all, I am new to Clojure, but not Java or LISP (I used to work at LMI). I am considering a project written in a mixture of Clojure, Java and Groovy. Clojure for the concurrent inner loop. Groovy/Grails for the Web UI. And lots of Java reused from other projects. How would I debug something like this? Can I compile Clojure so that a standard Java debugger understands it? I don't know about Groovy, but some people have used standard Java debuggers to debug Clojure code. For example: 1. Read Rich's section on debugging in Getting Started: http://clojure.org/getting_started#toc5 2. Have a look at my blog post: http://bc.tech.coop/blog/081023.html 3. There was a recent discussion on this group where another individual had some problems getting JSwat working: http://groups.google.com/group/clojure/browse_thread/thread/403e593c86c2893f# 4. A general search for debugger on this group will also bring up some other relevant threads. Is there a better way? Better is subjective. ;-) You could use traditional lisp debugging techniques as well. I've covered some of these on my blog: http://bc.tech.coop/blog/040628.html Cheers, Bill --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---