Re: Keyboard Input in Applets
Hi, On Jun 14, 8:55 am, rob levy wrote: > (ns ... > ... > (:gen-class > :extends javax.swing.JApplet > ??? :implements java.awt.event.KeyListener)) :implements [java.awt.event.KeyListener] Note: vector. > (defn -init [#^JApplet applet] > ??? addKeyListener ) You probably want :post-init. > (defn -keyPressed [#^JApplet applet #^KeyEvent event] > (let [key (. event getKeyCode)] > (cond (= key (. KeyEvent VK_LEFT)) (dosync (ref-set message "left")) > (= key (. KeyEvent VK_RIGHT)) (dosync (ref-set message "right")) > (= key (. KeyEvent VK_UP)) (dosync (ref-set message "up")) > (= key (. KeyEvent VK_DOWN)) (dosync (ref-set message "down" You can simplify this with condp. (condp = key KeyEvent/VK_LEFT KeyEvent/VK_RIGHT KeyEvent/VK_UP KeyEvent/VK_DOWN ) Concerning the question how to make the applet respond: Dunno what the best way is. I would probably put the KeyListener into a proxy, which drives the necessary changes (changing the refs in your example). In the GUI code I would add listeners to the refs, which update the UI on change. Sincerely Meikel PS: Shameless self-promotion: For proxy: http://kotka.de/blog/2010/03/proxy_gen-class_little_brother.html For gen-class: http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html For GUI driving: http://kotka.de/blog/2010/05/Decoupling_Logic_and_GUI.html Hope some of this helps. -- You 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: noob questions - Hello world + learning
Hello, I have a some comments (on comments and more :)) First this (comment . ) There are diffrent kind ofs comments. If you just want to note something you can do ; but mabey you want to have a example how to use something in your Code then use (comment ). With "defn" you creat a new function with a name. First switch the order of your function implementation (defn -main ([] (-main "world")) ([greetee] (println (str "Hello " greetee "!" What you are doing is implementing the -main method twise one for no arguments once for one argument ([] and [greetee]) This is a handy because you can make an easy and fast default implementation. An other way would be doing it like this (defn -main ([] (println "Hello world")) ([greetee] (println (str "Hello " greetee "!" But if you want to change something (Hello to helo or something) you would have to do this two times. So you just call your second implementation ([greetee] .. ) with "world". So a change got something in ([greetee] ) works for both implementations. So what does (str "Hello " greetee) do? Lets say you call -main like this (-main "nickik") then the greetee variable is a string. With (str ...) you make one string out of the arguments. (str "Hallo " "nickik") --> "Hallo nickik" than that is printed. If you call -main like this (-main 75) is will work because 75 will be converted to "75". Because you new some additional information. In most langauges you would have to tell the compiler what greetee is ( int or string ) these are what we call static languages but in clojure you dont have to. That is wath makes a language dynamic. So you can pass in everything that can be converted to a string. Interessting that you learn programming with clojure. I had to unlearn so many bad stuff that I was used to. If you want to use a lot of clojure you should learn git a liddle bit (there is a free book "Pro Git") most of clojure stuff people do is on github.org You can try the laprepl http://github.com/relevance/labrepl its made to help getting started Some links for you to finish this up some are probebly hard for you: http://clojure.blip.tv/ <-- videos about clojure (most of them from rich himself if you are hot for more surf infoq.com) The book that David Nolen mentiond: http://mitpress.mit.edu/sicp/full-text/book/book.html and Videos to help you learn you can found here: >From MIT 1986: http://www.youtube.com/watch?v=2Op3QLzMgSY and the next 20 vids but you can download them too just google them. Or if you like Berkeley more http://www.youtube.com/watch?v=zmYqShvVDh4 More on Programming in (its in java but it starts at lvl absolute ZERO) http://www.youtube.com/user/stanforduniversity?blend=2&ob=4#g/c/84A56BC7F4A1F852 But i recommend stike with the SICP book and courses they are harder but its worth it. Specaly if you like clojure. Sorry for tipping errors Great On Jun 11, 5:47 pm, Jared wrote: > Hi everyone, > > I'm 100% new to LISP, 95% new to Java, and 90% new to programming in > general. Where and how would you recommend learning Clojure? I'm > planning on buying Programming Clojure, but until then what would you > suggest? > > I got Netbeans working with Clojure and the default template is this: > > (comment > Sample clojure source file > ) > (ns com.yourcompany.defpackage > (:gen-class)) > > (defn -main > ([greetee] > (println (str "Hello " greetee "!"))) > ([] (-main "world"))) > > It ran and printed "Hello world!". Can anyone explain to me in detail > what each statement means. I'm particularly confused by: > > (comment > Sample clojure source file > ) > > I thought all comments began with ; ? I understand what println does > and that's it. > > Thanks in advance everyone. -- You 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: can not install clojure-test-mode using elpa (package.el)
On Mon, Jun 14, 2010 at 07:16, B Smith-Mannschott wrote: > On Sun, Jun 13, 2010 at 23:26, Phil Hagelberg wrote: >> There are some bugs in package.el that I have fixed in my personal fork but >> have not yet made it upstream yet. Try clearing out .emacs.d/elpa and trying >> again with the version at http://GitHub.com/technomancy/package.el and it >> should work although you will get byte compilation warnings. >> >> Sorry for the hassle. I hope my patches are applied soon so the situation >> improves. > > thanks! i am now able to install clojure, clojure-test, slime, > clojure-swank etc. without error. When I try to C-c C-k to load the > currently open clojure file into the slime repl, however, I get this: > > > Wrong number of args (4) passed to: basic$eval633$compile-file-for-emacs > [Thrown class java.lang.IllegalArgumentException] > > Restarts: > 0: [ABORT] Return to SLIME's top level. > > Backtrace: > 0: clojure.lang.AFn.throwArity(AFn.java:439) > 1: clojure.lang.AFn.invoke(AFn.java:51) > 2: clojure.lang.Var.invoke(Var.java:377) > 3: user$eval1304.invoke(NO_SOURCE_FILE) > 4: clojure.lang.Compiler.eval(Compiler.java:5421) > 5: clojure.lang.Compiler.eval(Compiler.java:5388) > 6: clojure.core$eval.invoke(core.clj:2370) > 7: swank.core$eval_in_emacs_package.invoke(core.clj:59) > 8: swank.core$eval_for_emacs.invoke(core.clj:128) > 9: clojure.lang.Var.invoke(Var.java:373) > 10: clojure.lang.AFn.applyToHelper(AFn.java:169) > 11: clojure.lang.Var.applyTo(Var.java:482) > 12: clojure.core$apply.invoke(core.clj:540) > 13: swank.core$eval_from_control.invoke(core.clj:66) > 14: swank.core$spawn_worker_thread$fn__367$fn__368.invoke(core.clj:172) > 15: clojure.lang.AFn.applyToHelper(AFn.java:159) > 16: clojure.lang.AFn.applyTo(AFn.java:151) > 17: clojure.core$apply.invoke(core.clj:540) > 18: swank.core$spawn_worker_thread$fn__367.doInvoke(core.clj:168) > 19: clojure.lang.RestFn.invoke(RestFn.java:398) > 20: clojure.lang.AFn.run(AFn.java:24) > > This used to work. Would it help to try to manually install > swank-clojure 1.2.0 do you think? (package.el only provides 1.1.0). > I'm developing against clojure 1.2.0-SNAPSHOT, while swank-clojure > 1.1.0 seems to use clojure 1.1.0. The "swank-clojure 1.1.0" I'm referring to above, is the version of the package as provided by package.el, which dumps a few jar files in ~/.swank-clojure: [smit...@oberon:~/.swank-clojure] $ ls -1 clojure-1.1.0-master-20091202.150145-1.jar clojure-contrib-1.1.0-master-20091212.205045-1.jar swank-clojure-1.1.0.jar But, I think that isn't actually relevant. At least, I was able to solve the problem by upgrading the swank-clojure dependency in my project's pom file form 1.1.0 to 1.2.1. --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ swank-clojure swank-clojure - 1.1.0 + 1.2.1 I tried 1.2.0, but that didn't work because of java.lang.Exception: No such var: swank.swank/ignore-protocol-version Somewhere in the recesses of my mind I remembered this problem being fixed with a 1.2.1 version, so I tried that and it worked. However, I do find it irritating that there manifestly *is* a release 1.2.1 available in Maven, and yet, no such tag has been defined in http://github.com/technomancy/swank-clojure.git Perhaps one should tag 0af258a279d42ea03ac1 as 1.2.1. http://github.com/technomancy/swank-clojure/commit/0af258a279d42ea03ac12782fb2700f3602e9a78 // Ben // Ben -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Colon (:) in comments?
OK. Thanks for the help to both of you. Regards, jf On 13 Jun, 21:27, Meikel Brandmeyer wrote: > Hi, > > Am 13.06.2010 um 19:50 schrieb Heinz N. Gies: > > > comment just is a function that says 'don't evaluate the stuff in here, it > > still needs to be correct clojure code you can either use: > > > ; TODO: x y z > > or > > #_(Todo: x y z) > > Note that after #_ it must also be valid code. > > 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
newbie: simple histogram problem
I'm attempting to write a simple histogram function: (defn create-histogram [f] (let [words (read-lines f) histo {}] (doall (map (fn [w] (assoc histo w (+1 (get histo w 0 words)) histo)) (create-histogram "./testwords") The input, 'f', is expected to be a file of words, as you'd get from '/usr/share/dict/words'. I don't see how to accumulate the results in the map, 'histo'. This is really a question of how does one map a function to a collection and accumulate the results... -Todd -- You 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: Bug in Clojure. Trouble with App Engine.
Thanks. Now it's work fine with array of arguments. On Jun 14, 12:34 am, Meikel Brandmeyer wrote: > Hi, > > Am 12.06.2010 um 06:08 schrieb zahardzhan: > > > When i eval code from Google App Engine SDK clojure throws very > > strange class cast exception. I put this code into Java class, then > > eval this class from clojure - and there is no problem. > > > Is this Clojure bug? > > No. Try (LocalServiceTestHelper. (into-array [ > (LocalUserServiceTestConfig.)])). The Constructor is variadic, ie. you have > to pass it an array as is indicated by the [L...; in the error message. > > Sincerely > Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: newbie: simple histogram problem
On 14 Jun 2010, at 01:14, Todd wrote: > I'm attempting to write a simple histogram function: > > > (defn create-histogram [f] > (let >[words (read-lines f) > histo {}] >(doall > (map >(fn [w] (assoc histo w (+1 (get histo w 0 >words)) >histo)) > > (create-histogram "./testwords") > > > The input, 'f', is expected to be a file of words, as you'd get from > '/usr/share/dict/words'. > > I don't see how to accumulate the results in the map, 'histo'. This is really > a question of how does one map a function to a collection and accumulate the > results... "reduce" is the canonical way to combine a number of input values into a single result. Here you're constructing a histogram from a sequence of words, so try something like the following: (defn create-histogram [f] (reduce (fn [hist word] (merge-with + hist {word 1})) {} (read-lines f))) -Steve -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: newbie: simple histogram problem
On 14 Jun 2010, at 12:37, Steve Purcell wrote: > On 14 Jun 2010, at 01:14, Todd wrote: > >> I'm attempting to write a simple histogram function: >> >> >> (defn create-histogram [f] >> (let >> [words (read-lines f) >>histo {}] >> (doall >> (map >> (fn [w] (assoc histo w (+1 (get histo w 0 >> words)) >> histo)) >> >> (create-histogram "./testwords") >> >> >> The input, 'f', is expected to be a file of words, as you'd get from >> '/usr/share/dict/words'. >> >> I don't see how to accumulate the results in the map, 'histo'. This is >> really a question of how does one map a function to a collection and >> accumulate the results... > > > "reduce" is the canonical way to combine a number of input values into a > single result. Here you're constructing a histogram from a sequence of words, > so try something like the following: > > (defn create-histogram [f] > (reduce (fn [hist word] > (merge-with + hist {word 1})) > {} > (read-lines f))) Or even: (defn create-histogram [f] (apply merge-with + (map array-map (read-lines f) (repeat 1 In any case, your original code could be re-written to use 'reduce' like this: (defn create-histogram [f] (let [words (read-lines f)] (reduce (fn [histo w] (assoc histo w (inc (get histo w 0 {} words))) -Steve -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Commercially-supported, polished Clojure development environment
Hi Chas, I'm interested in being able to consult the detail of the answers (not just the summary view), 'cause I guess there could be interesting stuff in the "free form" parts of it (and the summary page just presents a few of these answers). 2010/6/9 Chas Emerick : > Following the results from the State of Clojure survey, and some follow-up > comments from some in #clojure indicating that they, too, would like to see > a commercially-supported Clojure development environment (adjectives > included "badass", "no-compromise", and the like, just to give you the > flavor), I went ahead and started yet another Google Docs form (I guess I > might be looking for nails to drive with this new hammer I've found ;-)): > > Petition / Market Research: For the development of a commercially-supported, > polished Clojure development environment > http://spreadsheets.google.com/viewform?formkey=dHVEYUg3V3dMZjc0VDdNUFhWMGJ2bmc6MQ > > If you're at all interested in the topic of Clojure development > environments, and you'd potentially be interested in paying real money for > one that presumably improved upon your current environment by some > remarkable amount, take a look at the survey, the accompanying wiki page, > and add yourself to the waiting list, as it were. > > Cheers, > > - Chas > > -- > You 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: Commercially-supported, polished Clojure development environment
On 14/06/2010, at 9:25 PM, Laurent PETIT wrote: > Hi Chas, > > I'm interested in being able to consult the detail of the answers (not > just the summary view), 'cause I guess there could be interesting > stuff in the "free form" parts of it (and the summary page just > presents a few of these answers). +1 Antony Blakey -- CTO, Linkuistics Pty Ltd Ph: 0438 840 787 What can be done with fewer [assumptions] is done in vain with more -- William of Ockham (ca. 1285-1349) -- You 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
Unexpected conj behavior
Okay, I was doing some quick experiments with conj today, and I stumbled across the following behavior. The first step works great. user=> (conj {} [:a 1]) {:a 1} Then I hit some different casting errors: user=> (conj {} (seq [:a 1])) # user=> (conj {} '(:a 1)) # This behavior becomes a pain when trying to use into: ;Good user=> (into {} [[:a 1] [:b 2] [:c 3] [:d 4]]) {:a 1, :b 2, :c 3, :d 4} ;Bad user=> (into {} (partition 2 [:a 1 :b 2 :c 3 :d 4])) # Is this a bug? Should the conj method of APersistentMap be re-written to cast a wider variety of stuff to a Map$Entry? Or, is this just the behavior of conj, and I should get used to it? Sean -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Requesting Feedback on new Relational Mapping lib for Clojure
Hello group. I have been working on a relational mapping library for Clojure named Carte. http://github.com/brentonashworth/carte The current version is what I would consider to be a working prototype and I would love to get feedback from the community before I do much more work on this. The project includes a rather lengthy README. Mainly, I am interested in constructive criticism of the ideas and examples contained in the README but if you would like to jump into the code and critique that, that would be great. This is my idea of an idiomatic Clojure relational mapping library. Do you think I am on the right track? If not, what would that look like? What would Rich do? This project is being developing for my own immediate needs but I would be interested in improving it outside of the scope of my work based on your feedback. Thank you, Brenton -- You 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: Why does clojure-http stores cookies in a ref instead of an atom
> I'm a clojure newbie trying to understand when to use atoms versus refs. > In clojure-http.resourcefully, if you use the with-cookies macro stores the > cookies in a thread local ref. Why a ref and not an atom? My impression is > that refs are for when you need to coordinate changes to more than one > variable, or maybe if you need triggered validations. I looked at: http://github.com/technomancy/clojure-http-client/blob/master/src/clojure_http/resourcefully.clj Without making claims to the intent of the original author, my interpretation is that *cookies* is a globally shared resource (a namespace-global var), and thus a ref is used for co-ordinated updates. In the case of with-cookies, the intent is a thread-local binding overriding the cookies. If it were not still bound to a var, (save-cookies..) and the code in the define-method macro would have to support *cookies* being either a ref or a non-ref (in addition to 'nil' which is already special-cased). My guess is that it is just the simpler way to implement it, and it also means the same code paths are taken regardless of whether or not you're inside (with-cookies ...). Presumably HTTP is expensive enough anyway that eliminating the overhead associated with a ref can be considered an irrelevant overhead. -- / Peter Schuller -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Akamai Purchases Velocitude < Job Opening
This may be of interest to some of you. Recently Akamai has purchased the mobile services company Velocitude and is seeking software engineers in the Cambridge MA area with experience with functional programming. I don't have a direct link to the job requirements description, but if you go to http://jobs.akamai.com/ and search for "Senior Software Engineer Mobile", it will be the first job. http://www.akamai.com/html/about/press/releases/2010/press_061010.html Jeffrey Straszheim Senior Software Engineer [cid:3359372628_3177949] Office: 954.652.2243 Cell: 561.504.9913 Akamai Technologies 8 Cambridge Center Cambridge, MA 02142 -- You 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<>
ClojureCheck 2.0
Dear fellow Clojurians, I just released ClojureCheck 2.0 into the wild. It is a clojure.test extension that allows to generate input data of a desired structure to test code with random input. It is similar to fact[1] or Haskell's QuickCheck[2]. I wrote a short introductory blog post with a example. Not necessarily a good one, but it should show the look'n'feel of the library: http://kotka.de/blog/2010/06/ClojureCheck_is_back.html ClojureCheck is available from Clojars as [clojurecheck "2.0.0"]. The source is available at http://bitbucket.org/kotarak/clojurecheck. Please feel free to try and test it. In particular I'd appreciate feedback concerning the API. Sincerely Meikel [1]: http://github.com/weavejester/fact [2]: http://en.wikipedia.org/wiki/QuickCheck -- You 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: ClojureCheck 2.0
Useful, but not that sort of thing I'd ever think to look for unless I had read about it. Is there a wiki page somewhere that lists all this little libraries with a one line description? Would be great to just read a list of ideas and check a few out that hadn't thought about before. On Jun 14, 8:29 pm, Meikel Brandmeyer wrote: > Dear fellow Clojurians, > > I just released ClojureCheck 2.0 into the wild. It is a clojure.test > extension that allows to generate input data of a desired structure to test > code with random input. It is similar to fact[1] or Haskell's QuickCheck[2]. > I wrote a short introductory blog post with a example. Not necessarily a good > one, but it should show the look'n'feel of the > library:http://kotka.de/blog/2010/06/ClojureCheck_is_back.html > > ClojureCheck is available from Clojars as [clojurecheck "2.0.0"]. The source > is available athttp://bitbucket.org/kotarak/clojurecheck. > > Please feel free to try and test it. In particular I'd appreciate feedback > concerning the API. > > Sincerely > Meikel > > [1]:http://github.com/weavejester/fact > [2]:http://en.wikipedia.org/wiki/QuickCheck -- You 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: Mac Emacs users: which version do you prefer (Aquamacs, Carbon Emacs, other?)
On Sun, Jun 13, 2010 at 8:22 AM, Rob Lachlan wrote: > Probably, but I'm at a loss to figure out exactly what it might be. I > cleaned emacs off, along with the .emacs.d directory, reinstalled, and > the problem reappeared. I'm not touching it right now since, as I > mentioned, I managed too bootstrap using aquamacs. I don't think this is a GNU Emacs vs Aquamacs problem; there is a known bug in the official version of package.el that causes errors like the one you describe. I've fixed the problem in my fork of package.el, but it hasn't been accepted upstream yet. I will update the swank readme to point to this. Also note that as per the readme, the swank-clojure elisp package is no longer needed; you just need clojure-mode and slime-repl on the Emacs side and swank-clojure on the Clojure side. -Phil -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Why does clojure-http stores cookies in a ref instead of an atom
On Fri, Jun 11, 2010 at 8:45 AM, Steve Molitor wrote: > I'm a clojure newbie trying to understand when to use atoms versus refs. > In clojure-http.resourcefully, if you use the with-cookies macro stores the > cookies in a thread local ref. Why a ref and not an atom? My impression is > that refs are for when you need to coordinate changes to more than one > variable, or maybe if you need triggered validations. Actually you're correct; an atom would be better here. I wrote that code a long time ago and haven't used or looked at it since, but there's absolutely no reason to pull in the STM for state changes like that. -Phil -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Unexpected conj behavior
On Jun 14, 11:06 am, Sean Devlin wrote: > ;Bad > user=> (into {} (partition 2 [:a 1 :b 2 :c 3 :d 4])) This can, of course, be (into {} (map vec (partition 2 [:a 1 :b 2 :c 3 :d 4]))) I think the requirement is that the argument to APersistentMap.conj should implement Associative, which vectors do but seqs do not (because they don't do random access). -S -- You 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: Keyboard Input in Applets
Meikel, Thank you! This gives me some ideas I'm going try. I read your blog posts too, great stuff. The new book by Vanderhart & Sierra serves as good documentation of proxy as well. I have not yet come across a good "Java for Clojure Programmers" guide that really explores all the hairy problems of operating Java libraries via Clojure. Maybe there should be a wiki for this. I think a lot of Clojurers are dynamic language folk like me who have avoided Java for the most part (actually my computer science courses used Java, so I could only imagine the learning curve must be even worse for some people). Rob On Mon, Jun 14, 2010 at 3:52 AM, Meikel Brandmeyer wrote: > Hi, > > On Jun 14, 8:55 am, rob levy wrote: > > > (ns ... > > ... > > (:gen-class > > :extends javax.swing.JApplet > > ??? :implements java.awt.event.KeyListener)) > > :implements [java.awt.event.KeyListener] > > Note: vector. > > > (defn -init [#^JApplet applet] > > ??? addKeyListener ) > > You probably want :post-init. > > > (defn -keyPressed [#^JApplet applet #^KeyEvent event] > > (let [key (. event getKeyCode)] > > (cond (= key (. KeyEvent VK_LEFT)) (dosync (ref-set message "left")) > > (= key (. KeyEvent VK_RIGHT)) (dosync (ref-set message > "right")) > > (= key (. KeyEvent VK_UP))(dosync (ref-set message "up")) > > (= key (. KeyEvent VK_DOWN)) (dosync (ref-set message > "down" > > You can simplify this with condp. > > (condp = key > KeyEvent/VK_LEFT > KeyEvent/VK_RIGHT > KeyEvent/VK_UP > KeyEvent/VK_DOWN ) > > Concerning the question how to make the applet respond: Dunno what the > best way is. I would probably put the KeyListener into a proxy, which > drives the necessary changes (changing the refs in your example). In > the GUI code I would add listeners to the refs, which update the UI on > change. > > Sincerely > Meikel > > PS: Shameless self-promotion: > For proxy: > http://kotka.de/blog/2010/03/proxy_gen-class_little_brother.html > For gen-class: > http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html > For GUI driving: > http://kotka.de/blog/2010/05/Decoupling_Logic_and_GUI.html > > Hope some of this helps. > > -- > You 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
ANN: clojure-maven-plugin 1.3.3
Hey all, Pushed out a new release of the maven plugin earlier in the week - clojure-maven-plugin 1.3.3 changes: * Changes to clojure:swank * Now generates a temporary .clj file to execute when running swank. * Now uses test dependencies rather than compile dependencies * Changes to namespace discovery * Fixes to namespace discovery for "(ns$" * Now ignores files/directories starting with . * Added options: copyAllCompiledNamespaces, copyDeclaredNamespaceOnly, and copiedNamespaces to copy .clj source files to target directory * Changes to clojure:run * Added support for -Dclojure.script command line override * Added support for classpath loaded scripts via @-prefixed paths Thanks to Chas Emerick, Antony Blakey, Nelson Morris, and jgeraerts ( real name escapes me off hand ) for patches in this release. Mark -- Pull me down under... -- You 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