Re: com.stuartsierra/component ring/compojure example
Here is a toy app that downloads nzbs from usenet: https://github.com/gar3thjon3s/leacher It's not documented, but it works. The component stuff is hooked up here: https://github.com/gar3thjon3s/leacher/blob/master/src/clj/leacher/main.clj#L53 On 7 October 2014 12:33, JPatrick Davenport virmu...@gmail.com wrote: Hello, I'm trying to create a web app. I'm having the damnest time trying to figure out how to layer my application. I want to pass protocol implementations to the routes. The protocols define interacting with various data sources that I need down the way. I saw Stuart Sierra's talk about Component. It looks to satisfy my needs. What I can't find is an example project for component and compojure. Unfortunately the project com.stuartsierra/component is poorly named. Googling for component + compojure brings back mostly false positives. Does anyone have a gist or blog post about how to do this? Thanks, JPD -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: How did you learn Clojure?
A technique I use whenever I need to learn a new language is to write the same application I already have in another language. I generally choose downloading nzbs from usenet as it can involve a number of interesting programming techniques, at least enough to give you a pretty good idea of how a language handles things like: * threading and work queues (downloading files concurrently) * socket io (writing a simple nntp client) * xml processing (parsing nzb files) * binary encoding/decoding (yenc implementation) * curses style ui * web ui * command line arguments * configuration * signal handling * testing (haha kidding) TBH I usually get about 50% of the way through and have enough of a handle on the language at that point to abandon my efforts and move on. On Wed, Mar 26, 2014 at 7:22 PM, Daniel Higginbotham nonrecurs...@gmail.com wrote: Chiming in a bit late, but here was my path: * Read Land of Lisp by Conrad Barski. This was my first real contact with lisp and functional programming. I found it challenging, but the book is well-written and the technique of teaching through writing games was perfect for me. It uses common lisp which is almost baroque compared to Clojure, but it was helpful later in getting a better sense of Clojure's roots. Also, most of the classic lisp books out there use common lisp * Tried to write my own web-based game using common lisp. This was true fun and I learned a ton * Read On Lisp by Paul Graham. It is an excellent book * Was introduced to Clojure through a talk given by Alan Dipert at my workplace * Learned Clojure by skipping around Clojure in Action, Programming Clojure, and Clojure Programming. Settled on Clojure Programming. * projecteuler.net has been a good help * I've been teaching Clojure to folks at work, which forces me to deeply understand the material * At the same time, I've kept building little web apps to solidify my knowledge. One of them, http://gratefulplace.com, is actually used :) I feel like I know enough to get stuff done, but there's still so much more to learn. Most recently I've been brushing up on math/logic so that I can better understand the more mathy texts whenever I encounter them. On Thursday, March 20, 2014 9:08:41 PM UTC-4, Marcus Blankenship wrote: Hi Folks, I'm a post technical PM who's fascinated by Clojure, and want to learn it, but am having a hard time without a real project to work on. It's actually excited me so much I'm considering hanging up my PM hat and diving back in the programmer pool again! My problem appears to be 1) focus, and 2) fear. Focus because I can't (yet) earn a living on a clojure project, so it must be done during off hours. Fear because it's harder and more different than the old OO languages I've used in the past. So I'm curious: how did you learn Clojure well enough to be proficient with it, or how are you working on learning it? Anyone else facing the focus + fear dilemma? Sent from my iPhone -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Contributors needed for Rouge (Clojure on Ruby)
Why not just use Ruby or (my preference) Python? Both are great for quick CLI apps / scripts. Best tool for the job, and all that? On Sat, Jan 4, 2014 at 8:43 AM, gvim gvi...@gmail.com wrote: I have recently moved most of my work to Clojure and Clojurescript but neither of these implementations seem suitable for non-http scripting, for which I currently use Ruby. So, you can imagine my elation when I discovered Rouge which is Clojure implemented on Ruby: https://github.com/rouge-lang/rouge The project looks fantastic but they seem to be short of contributors. My programming skills are nowhere near advanced enough to work on this myself so, please, if any of you Clojurians have proficiency in Ruby and Clojure please consider contributing. I looked at Python's Hy (hylang.org) which is an excellent project in its own right and is heavily influenced by Clojure but its taregt is generic Lisp 1 rather than Clojure. Rouge will enable Clojure to occupy the non-http scripting space without competing directly with Clojure and Clojurescript. gvim -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: is there a tutorial about working at the REPL?
There are at least some keyboard shortcuts you should be familiar with for loading / compiling namespaces. Look a the Using the REPL section of this: http://clojure-doc.org/articles/tutorials/emacs.html On Sat, Dec 28, 2013 at 7:38 PM, larry google groups lawrencecloj...@gmail.com wrote: I have been working with Clojure now some of the time for the last 18 months, so I am no longer a complete noob. But I still have many questions about how to work at the REPL. In particular, I don't understand how the REPL interacts with the class path. I have an app that is working. When I need to make changes to it, my workflow goes like this: 1.) start emacs 2.) open a file in the project that I want to work in. I usually start by opening up the project.clj fie. 3.) type nrepl-jack-in to launch the repl. 4.) load whatever file holds the (main-) function that starts the app. So for me, for instance, it might be: (load-file “src/admin/core.clj”) 5.) switch to that namespace: (in-ns ‘admin.core) 6.) call the function that starts my app: (main-). Give it any arguments that it needs. 7.) do work. Moving around inside of the project tends to consist of a lot of loading a file: (load-file “src/admin/controller.clj”) and then switching to the namespace: (in-ns ‘admin.controller) However, I have a config file at: /resources/config/schema.edn If I open a terminal, cd to the top level of the directories where this app lives, and then run lein uberjar I get an app that works just fine if I do: java -jar admin-1-standalone.jar But when I want to work on this app at the REPL, the app seems unable to find the schema.edn file. You can see my REPL session below. The function (initiate-forms) has this line: (read-string (slurp (clojure.java.io/resource config/schema.edn))) This should run when the app starts and then it is stored in secretary/interactions, but below you can see that secretary/interactions is empty. Why does this work when I run the app from the command line? What do I need to do to get this work when I'm in the REPL? I am assuming the problem here has something to do with the classpath, please tell me if I'm wrong. admin.controller (load-file src/admin/core.clj) #'admin.core/-main admin.controller (in-ns 'admin.core) #Namespace admin.core admin.core (ns-publics 'admin.core) {-main #'admin.core/-main} admin.core (-main 35000) App 'TMA admin' is starting. If no port is specified then we will default to port 34000. You can set this app to production mode, where debugging output to the terminal is surpressed, by starting it like this: java -jar target/admin-1-standalone.jar 30001 production #Server org.eclipse.jetty.server.Server@70faf7c7 admin.core (load-file src/admin/secretary.clj) {:dire/error-handlers {java.lang.NullPointerException #secretary$eval1798$fn__1799 admin.secretary$eval1798$fn__1799@7a4311f9}, :ns #Namespace admin.queries, :name process-some-fetch-function, :arglists ([function-to-call-to-get-data-from-monger map-for-queries]), :column 1, :line 124, :file admin/queries.clj} admin.core (in-ns 'admin.secretary) #Namespace admin.secretary admin.secretary interactions #Atom@4d1fafe8: {} admin.secretary @interactions {} admin.secretary (load-file src/admin/startup.clj) #'admin.startup/start-channels admin.secretary (in-ns 'admin.startup) #Namespace admin.startup admin.startup (ns-publics 'admin.startup) {start-channels #'admin.startup/start-channels, initiate-forms #'admin.startup/initiate-forms, connect-to-database #'admin.startup/connect-to-database, set-the-current-debugging-level #'admin.startup/set-the-current-debugging-level} admin.startup (start-channels) nil admin.startup (initiate-forms) cannot read object -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure
Re: T-shirts?
This shirt appears to be complecting fashion, programming, AND advertising. On Mon, Nov 25, 2013 at 11:17 AM, Laurent PETIT laurent.pe...@gmail.comwrote: Hey Bruce, 2013/11/25 Bruce Durling b...@otfrom.com: Yay! Thanks Rich! Good picture of you. Have you been working out before taking those shots in the t-shirt? It's a direct side-effect of following Clojure's strengths in your life: simplicity, power, focus ;-) -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [ANN] optparse-clj: Functional GNU-style command line options parsing
Hey guns, Yeah sounds good, I don't have admin access to add you as a developer so will ask on the clojure-dev mailing list to see who can do it and cc you on that. Cheers, Gaz On Wed, Nov 20, 2013 at 6:40 PM, guns s...@sungpae.com wrote: On Wed 20 Nov 2013 at 06:32:49PM -0600, guns wrote: The formatting is a bit ugly, so here is a plain text version: https://gist.github.com/guns/7573819/raw/26fc5a741d78b9cf1753fcde1a071dd467d44b4f/tools.cli.proposal.mail Sorry for the double post. The url above should be: https://gist.github.com/guns/7573819/raw The first one posted contains an error. guns -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [ANN]: clj.jdbc 0.1-beta1 - Alternative implementation of jdbc wrapper for clojure.
Because there is no patch for human stupidity? On Tue, Nov 19, 2013 at 1:35 PM, Sean Corfield seancorfi...@gmail.comwrote: On Sun, Nov 17, 2013 at 1:57 AM, Andrey Antukh n...@niwi.be wrote: Additionally I have copied some useful functions like parsing dbspec to URI or a map of protocol-cases and the rest are written from scratch. Looking through the source code, there are quite a few functions copied directly from parts of java.jdbc - even maintaining docstrings, making it clear you copied and pasted them - but I notice that you have not maintained the copyright or license from java.jdbc. Would you like to explain why you have copied open source software without respecting the license and contributors? -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [ANN]: clj.jdbc 0.1-beta1 - Alternative implementation of jdbc wrapper for clojure.
Whoops, sorry looks like my intended light-hearted sarcasm based on one of the email signatures in the thread got mis-interpreted. Hard to express in an email, perhaps a cheeky :P after would have let you know I wasn't being particularly serious! No offense intended, or taken :) On Tue, Nov 19, 2013 at 4:25 PM, Softaddicts lprefonta...@softaddicts.cawrote: Gaz, excuse me if I misunderstood you, I reread your reply and it was not clear to me to whom you were referring in your comment. I still stand by what I said toward the op. Saying that if rewritten the code would be the same as the original is a lame excuse, it's the same as all that internet cheating thing in schools. Unexcusable. Luc P. You have the typical profile of people who do not understand open source. To you, open source is the same thing has a side hobby, ... with lack of commitment and seriousness. How do you expect open source software quality to improve if each of us starts to spin off our own flavor of the same lib ? How is this a constructive cooperating effort ? How can open source software be used in production in this context ? Some people are using this stuff to build serious solutions to hard problems. I will not even rant about copying without the copyright. It's the overall lack of logic and self centric egoism that you exhibit that makes me rant. You should apply the maxim you have thrown in this thread to yourself. You are much more representative of it than anyone else I saw on this mailing list in 5 years. Punk. Luc P. Because there is no patch for human stupidity? On Tue, Nov 19, 2013 at 1:35 PM, Sean Corfield seancorfi...@gmail.com wrote: On Sun, Nov 17, 2013 at 1:57 AM, Andrey Antukh n...@niwi.be wrote: Additionally I have copied some useful functions like parsing dbspec to URI or a map of protocol-cases and the rest are written from scratch. Looking through the source code, there are quite a few functions copied directly from parts of java.jdbc - even maintaining docstrings, making it clear you copied and pasted them - but I notice that you have not maintained the copyright or license from java.jdbc. Would you like to explain why you have copied open source software without respecting the license and contributors? -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Softaddictslprefonta...@softaddicts.ca sent by ibisMail from my ipad! -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Softaddictslprefonta...@softaddicts.ca sent by
Re: [Job spam] Write Clojure in your pajamas, for decent money in a pleasant company, remote pairing all the time
If you're account had a picture like his, YES. On Mon, Nov 18, 2013 at 5:45 PM, Tony Tam ttasteri...@gmail.com wrote: Hi, I'm always curious about remarks like this: A link to your Github profile counts for much more than a stellar resume. Doesn't have to be in Clojure. If I sent you a like to a github profile that looked like yours ( https://github.com/alexeyv?tab=repositories), would I ever get an answer? I mean, it's very probable that all your activity is going into private repos. -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Job spam] Write Clojure in your pajamas, for decent money in a pleasant company, remote pairing all the time
*your :) On Mon, Nov 18, 2013 at 9:46 PM, gaz jones gareth.e.jo...@gmail.com wrote: If you're account had a picture like his, YES. On Mon, Nov 18, 2013 at 5:45 PM, Tony Tam ttasteri...@gmail.com wrote: Hi, I'm always curious about remarks like this: A link to your Github profile counts for much more than a stellar resume. Doesn't have to be in Clojure. If I sent you a like to a github profile that looked like yours ( https://github.com/alexeyv?tab=repositories), would I ever get an answer? I mean, it's very probable that all your activity is going into private repos. -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Do web apps need Clojure?
There is no reason not to consider using a combination of both technologies. I have found Clojure is excellent for writing http services (for example sending/receiving JSON), but is a bit weak in comparison to say the combination of ruby and haml for building UIs quickly. On Thu, Nov 14, 2013 at 10:22 AM, Brian Craft craft.br...@gmail.com wrote: On Thursday, November 14, 2013 2:28:51 AM UTC-8, Sean Johnson wrote: Framework vs. ecosystem of interoperable libraries. The monolithic framework (see Rails and Django) is not the way web development is done in Clojure. Instead imagine the Clojure world as a set of legos. You get to build whatever you want with your legos, selecting just the blocks you need, in the colors and sizes you want, and they all snap together [1]. The benefit to this approach is simplicity. There is a LOT to know about the Rails and Django frameworks, as they are big, mature things that have grown to solve all the common web development needs, and you start your development with ALL of that framework. Your starting point with Clojure on the other hand is much simpler. It will seem too simple... at first you'll be wondering... where is all the stuff? You start with maybe just ring and compojure (web middleware and routing) and a few lines of your code and your first couple of stories are already complete. You add libraries as you find you need them as you build out your app over time, but at all times your app is as simple as it can be, and only has the stuff it needs. It's therefore much easier to understand and less a big ball of mud. I don't believe the legos analogy is very accurate for clojure. Or, rather, it's more of a vision than a reality. I'm unaware of any libraries in clojure that you can piece together to give you the features of django-south, django admin, and the forms/validation/db layers, for example. Today, clojure web libraries are more like an auto parts store: your chance of putting together a complete car from the inventory is slim indeed, and your chance of doing it in a timely fashion is exactly zero. There are about a dozen migration libraries for clojure, for example, but none of them integrate very well with the other libraries because there isn't much in the way of a data modeling framework for the different components to leverage. Also, I don't think any of them provide the simplicity of south, where your data model is declared in one place (rather than in a sequence of sql commands that you have to interpret to deduce the final data model), and migrations are derived from changes in the data model. The putting of things together is the hard part of software engineering. This makes a huge difference in development time. Clean algorithms are easy in comparison. Rich talks about the importance of taking things apart, but you can't take things apart that never fit together in the first place. IIRC he actually suggested that one take things apart such that they fit together again. I agree with this, but I don't think it describes much of clojure web tooling today. Also, the overwhelming majority of db and web work is boilerplate. That's what django provides: all the mindless boilerplate that is completely uninteresting to your problem domain, but necessary to launch a web site. With the current clojure web tools, there is no solution for most of that boilerplate, which can easily add an order of magnitude to your development time. And again, I will have to reevaluate all of this in light of caribou, which appears to address much of it. Also, I'd be very happy to hear that I'm wrong, if anyone has example projects to show, or libraries I've missed. -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails
Re: How to go about 'proving' why dynamically typed languages are better
Martin Odersky gave a keynote at Strangeloop this year called The Trouble With Types (https://thestrangeloop.com/sessions/the-trouble-with-types) which made me never want to use a type system again (probably the exact opposite of his intention). The video should be coming out on infoq at some point: (http://www.infoq.com/conferences/strangeloop2013/). I've never looked at Scala before and I'm pretty sure I never will after sitting through that... On Mon, Oct 7, 2013 at 9:26 AM, juan.facorro juan.faco...@gmail.com wrote: Thanks for the link! I really liked the interview, it was interesting and fun to watch. J On Monday, October 7, 2013 9:49:24 AM UTC+9, brad bowman wrote: zcaudate z...@caudate.me Oct 05 08:35PM -0700 I'm a little bit miffed over this current craze of `types` and `correctness` of programs. It smells to me of the whole `object` craze of the last two decades. I agree that types (like objects) have their uses, especially in very well defined problems, but they have got me in trouble over and over again when I am working in an area where the goal is unclear and requirements are constantly changing. Joe Armstrong and Simon Peyton Jones discuss Erlang and Haskell http://www.infoq.com/**interviews/armstrong-peyton-**jones-erlang-haskellhttp://www.infoq.com/interviews/armstrong-peyton-jones-erlang-haskell This interview covers some of the strong-types vs flexible development (apparent) dichotomy, but in a playful, open and non-dogmatic way. (catmatic?) Simon Peyton Jones is one of the Haskell leaders, yet admits to being envious of type-free generics. Joe Armstrong of Erlang fame also sees the benefit to thinking in and annotating types. These two are both leaders of typed or dynamic cults but have a pleasant friendly and frank conversation about the issues. (Erlang's Dialyzer sounds somewhat like core.typed) A sample: SPJ: So, I've told you what I most envy about Erlang. What do you most envy about Haskell? JA: All the types. I mean they're very nice. I wish we had them. On the other hand, wouldn't you love to have all these generic turn-to-binary, these sort of things? How can you live without them? SPJ: I have a little bit of residual envy about generics. JA: You just take anything and compare it to the serializer and then send it? SPJ: That's sinfully easy, and shouldn't be allowed. So if these two can agree that there's strengths and weaknesses in both approaches, that settles it for me. It's a matter of knowing your trade-offs and choosing your tools appropriately. My suspicion is that type affinity is related to some trait of personality, and so trying to prove superiority is a likely to work as proving you are right in any other clash of personalities. Brad -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [ANN] optparse-clj: Functional GNU-style command line options parsing
Hey, i am the current maintainer of tools.cli - i have very little time to make any changes to it at the moment (kids :) ). I'm not sure what the process is for adding you as a developer or transferring ownership etc but if I'm happy to do so as I have no further plans for working on it. Thanks, Gaz On Sat, Aug 24, 2013 at 9:44 PM, guns s...@sungpae.com wrote: On Fri 23 Aug 2013 at 05:02:50PM -0700, Paul deGrandis wrote: Guns, Have you signed a Clojure CA yet? I'd love to help get this merged into tools.cli Okay, since there is interest, I will mail a CA on Monday morning. Paul, if you are a maintainer or committer of tools.cli, I would be happy to submit the patch to you. guns -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Wrapping LevelDB with ring/compojure app
Instead of using the var #'web/app in run-jetty, use a function that takes your main-db as an argument and returns the routes for your app. You can use the compojure.core/routes to build your app routes rather than using a global var. On Fri, Jul 19, 2013 at 3:42 AM, Tarik Ansari tari...@gmail.com wrote: Hello Folks, I am a complete Clojure newbie and trying to achieve something pretty simple and looking for an idiomatic, if I can make it work at all, way to do it. My issue is I need to retain the LevelDB descriptor and share it between requests, LevelDB is already thread-safe. For example: (defn -main I don't do a whole lot ... yet. [ args] (println Opening LevelDB file in db/main) (with-open [main-db (db/open db/main)] (println Running server on port 3000) (run-jetty #'web/app {:port 3000}))) Now, how can I access that main-db descriptor in my requests handlers? This, obviously won't work, as main-db is not defined in web/app: (GET /test [] (db/put main-db (.getBytes testKey2) (.getBytes testValue2)) h1Hello World/h1) PS: If it helps anyone for setup, I have made a Clojar for the LevelDB JNI Clojure wrapper based on Sedward's: https://clojars.org/org.clojars.aircart/leveldb-clj Thanks in advance for your insight/help! -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: run-jetty not working in a virtualbox vm?
Just to check - you have set :join? false so the thread will not block until the server ends - are you doing this intentionally and blocking the thread elsewhere? On Fri, Jul 12, 2013 at 8:45 PM, Daniel Higginbotham nonrecurs...@gmail.com wrote: I'm trying to start a jetty server on a virtualbox vm (ubuntu 12.04 32 bit) by running the following: (run-jetty #'app {:port (Integer. (get (System/getenv) PORT 8080)) :join? false}) However, I can't connect to the server. If I run netstat -lp the java process doesn't show up and it looks as if nothing's listening on 8080. However, if I run the above run-jetty function again in a separate process I get the error message that another process is already bound to 8080. The weirdest part of all this is that the very first time I tried starting the server, it did start and I was actually able to reach it, but it only worked that one time. Has anyone run into this? Is there any way to debug the problem? Thanks! Daniel -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: parsing xml with zip, xml and clojure.data.zip
This may help: http://clojure-doc.org/articles/tutorials/parsing_xml_with_zippers.html On Wed, Jun 5, 2013 at 9:54 AM, Ryan Moore niclas1...@gmail.com wrote: Hi, I've read http://nakkaya.com/2009/12/07/zipping-xml-with-clojure/ and http://stackoverflow.com/questions/1194044/clojure-xml-parsing/9595315#comment24442712_9595315 , but the usage of (xml-) is still mysterious to me. If I have this for my xml file... (def myxml (zip-str level1 level2 a='the attribute' level3aText in level 3a/level3a level3bText in level 3b./level3b /level2 /level1)) My question is how the xml- function determines how nested you have to specify things. Eg (xml- myxml :level1 text) = () (xml- myxml :level2 text) = (Text in level 3aText in level 3b.) (xml- myxml :level2 :level3a text) = (Text in level 3a) The last call gives the text in 3a, but why don't you have to specifiy that it is under level 1 as well as level 2? Thanks -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: optional first map argument
You could look at the impl: https://github.com/weavejester/hiccup/blob/master/src/hiccup/def.clj On Mon, Jun 3, 2013 at 12:22 PM, Alice dofflt...@gmail.com wrote: I often need to do this when writing hiccup helper functions: (defn my-widget [ args] (let [attrs(if (map? (first args)) (first args) {}) contents (if (map? (first args)) (next args) args)] ... I found this post, but considering that it is 4 years old, is there any new library developed to help with this situation?. https://groups.google.com/group/clojure/browse_frm/thread/125a8af68813cd98 -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Beginners question - emacs compiling tests
The 'parse-args' function needs to be inside of the 'core.clj' file, not the 'core_test.clj' file - is that the case? (The reason it is failing is the first usage of 'parse-args' is before it has been defined). On Fri, May 31, 2013 at 1:31 AM, Adam Getchell adam.getch...@gmail.comwrote: On Tuesday, March 19, 2013 4:22:59 PM UTC-7, John SJ Anderson wrote: I had this same issue when working through the tutorial. The text makes it sound like you should replace the entire contents of the test file, but that's not the case -- you just need to replace the (deftest ...) form. (I ended up having to generate the project tree under a slightly different name to get a good copy of the file back.) I have a similar issue, except that I did leave my file intact: (ns command-line-args.core-test (:require [clojure.test :refer :all] [command-line-args.core :refer :all])) (deftest pairs-of-values (let [args [--server localhost --port 8080 --environment production]] (is (= {:server localhost :port 8080 :environment production} (parse-args args) (defn parse-args [args] {}) Results in: clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: parse-args in this context, compiling:(/Users/getchell/Projects/clojure/command-line-args/test/command_line_args/core_test.clj:12:12) at clojure.lang.Compiler.analyze (Compiler.java:6380) clojure.lang.Compiler.analyze (Compiler.java:6322) clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3573) clojure.lang.Compiler.analyzeSeq (Compiler.java:6562) clojure.lang.Compiler.analyze (Compiler.java:6361) clojure.lang.Compiler.analyze (Compiler.java:6322) clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3624) clojure.lang.Compiler.analyzeSeq (Compiler.java:6562) clojure.lang.Compiler.analyze (Compiler.java:6361) clojure.lang.Compiler.access$100 (Compiler.java:37) clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:5973) clojure.lang.Compiler.analyzeSeq (Compiler.java:6560) clojure.lang.Compiler.analyze (Compiler.java:6361) clojure.lang.Compiler.analyzeSeq (Compiler.java:6548) clojure.lang.Compiler.analyze (Compiler.java:6361) clojure.lang.Compiler.analyze (Compiler.java:6322) clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5708) clojure.lang.Compiler$TryExpr$Parser.parse (Compiler.java:2156) clojure.lang.Compiler.analyzeSeq (Compiler.java:6560) clojure.lang.Compiler.analyze (Compiler.java:6361) clojure.lang.Compiler.analyzeSeq (Compiler.java:6548) clojure.lang.Compiler.analyze (Compiler.java:6361) clojure.lang.Compiler.analyzeSeq (Compiler.java:6548) clojure.lang.Compiler.analyze (Compiler.java:6361) clojure.lang.Compiler.analyzeSeq (Compiler.java:6548) clojure.lang.Compiler.analyze (Compiler.java:6361) clojure.lang.Compiler.analyze (Compiler.java:6322) clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5708) clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6009) clojure.lang.Compiler.analyzeSeq (Compiler.java:6560) clojure.lang.Compiler.analyze (Compiler.java:6361) clojure.lang.Compiler.analyzeSeq (Compiler.java:6548) clojure.lang.Compiler.analyze (Compiler.java:6361) clojure.lang.Compiler.analyze (Compiler.java:6322) clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5708) clojure.lang.Compiler$FnMethod.parse (Compiler.java:5139) clojure.lang.Compiler$FnExpr.parse (Compiler.java:3751) clojure.lang.Compiler.analyzeSeq (Compiler.java:6558) clojure.lang.Compiler.analyze (Compiler.java:6361) clojure.lang.Compiler.analyzeSeq (Compiler.java:6548) clojure.lang.Compiler.analyze (Compiler.java:6361) clojure.lang.Compiler.analyze (Compiler.java:6322) clojure.lang.Compiler$MapExpr.parse (Compiler.java:2879) clojure.lang.Compiler.analyze (Compiler.java:6369) clojure.lang.Compiler.analyze (Compiler.java:6322) clojure.lang.Compiler$DefExpr$Parser.parse (Compiler.java:528) clojure.lang.Compiler.analyzeSeq (Compiler.java:6560) clojure.lang.Compiler.analyze (Compiler.java:6361) clojure.lang.Compiler.analyze (Compiler.java:6322) clojure.lang.Compiler.eval (Compiler.java:6623) clojure.lang.Compiler.load (Compiler.java:7064) command_line_args.core_test$eval1168.invoke (NO_SOURCE_FILE:1) clojure.lang.Compiler.eval (Compiler.java:6619) clojure.lang.Compiler.eval (Compiler.java:6582) clojure.core$eval.invoke (core.clj:2852) clojure.main$repl$read_eval_print__6588$fn__6591.invoke (main.clj:259) clojure.main$repl$read_eval_print__6588.invoke (main.clj:259) clojure.main$repl$fn__6597.invoke (main.clj:277) clojure.main$repl.doInvoke (main.clj:277) clojure.lang.RestFn.invoke (RestFn.java:1096)
Re: Local database recommendation?
Sqlite is worth a look. Never used it with the JVM, but I assume there is a JDBC driver for it. On Mon, May 27, 2013 at 1:01 AM, Zack Maril thewitzb...@gmail.com wrote: Use postgres. If it makes sense later on, then try a nosql solution. Until then, postgres will probably do 95% of what you want out of the box. -Zack On Sunday, May 26, 2013 6:20:02 PM UTC-4, Amirouche Boubekki wrote: 1) Is it structured aka. an object can have several fields possibly complex fields like list or hashmaps but also integers ? dates and uuids can be emulated with strings and integers 2) Do objects have relations ? a lot of relations ? 3) is the data schema fixed at compilation or do you need to have the schema to be dynamic ? Much of the data is conditional in a certain sense -- if it's an X, it's also a Y and it may be a W or a Z as well, but if it's a G it's certainly not a W, etc.; though simply storing a large number of boolean columns that may be unused by many of the table rows would be acceptable. The thing that makes me slightly dubious about relational here is that there will necessarily either be many columns unused by many rows, as there's a lot of data that's N/A unless certain other conditions are met; or else there will be many whole tables and a lot of expensive joins, as we have a table of Foos, with an isBar? column with either a BarID or a null, and a table of Bars with an isBaz? column, and a table of Bazzes with an isQuux? column, and then a need to do joins on *all* of those tables to run a query over a subset of Quuxes and have access to some Foo table columns in the results. This sort of thing points towards an object database more than any other sort, with inherited fields from superclasses, or a map database that performs well with lots of null/missing keys in most of the maps. But maybe a relational DB table with very many columns but relatively few used by any given row would perform OK. The only kind of object database that does ACID across documents on the JVM I know of is Tinkerpop' Blueprints. Blueprints is an abstraction layer on top of many graph databases among which Neo4j an OrientDB. The difference between a graph database and an object database is that «pointers» in a graph database are known at both ends. If you don't know graph you will need to learn a bit of it. Basicaly, if A is connected to B, B knows also about A being connected to it, which is not the case with a pointer. Otherwise said, like in relationnal database, you can ask for «all things connected to B» or «all things B connects to». The same query in an object database will cost more. On top of that it's schemaless, like an object database, but there is no notion of class, similar to what is found OO programming (even if you can model the graph to have the concept of classes). The DB must be able to grow larger then available RAM without crashing the JVM and the seqs resulting from queries like the above will also need to be able to get bigger than RAM. My own research suggests that H2 may be a good choice, but it's a standard SQL/relational DB and I'm not 100% sure that fits well with the type of data and querying noted above. Note though that not all querying will take that form; there'll also be strings, uuids, dates, and other such field types and the need to query on these and to join on some of them; also, to do less-than comparisons on dates. Depending on your speed needs and the speed of the database, a kv store can be enough, you serialize the data as strings and deserialize it when you need to do computation. Except that kv store are not easy to deal with when you have complex queries, but again it depends on the query. I expect they'd also have problems with transactional integrity if, say, there was a power cut during an update. Anything involving serialize the data as strings sounds unsuited to either the volume I'm envisioning or the need for consistency. It certainly wouldn't do to overwrite the file with half of an updated version of itself and then lose power! Keeping the previous version around as a .bak file is scarcely much better. It pretty much needs to be ACID since there will need to be coordinated changes to more than one bit of the data sometimes and having an update interrupted with only half the changes done, and having it stay in that half-done state, would potentially be disastrous. At least unqlite is a embeddable kv store that is ACID across several keys, you won't have data cut in half (based on what is advertised), I think berkley db is also transactional. Also I'm interested only in opensource software so there might be proprietary softwares that solve you problem best, but I doubt 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
Re: Structing Clojure tests/setup and tear down
I think I would use a macro: (defn with-bloomy-fn [bloomy body] (try (body) (finally (shut-down bloomy (defmacro with-bloomy [bloomy body] `(with-bloomy-fn ~bloomy (fn [] ~@body))) (deftest my-test (with-bloomy (create-a-bloomy) (...)) FYI code is untested, typing straight in so there may be typos etc. On Tue, May 21, 2013 at 10:05 AM, Colin Yates colin.ya...@gmail.com wrote: Hi Ulises, I don't think I am as that would require essentially a fixture per distinct combinations of test state, which is almost the same number of tests. Have I missed something? On 21 May 2013 15:51, Ulises ulises.cerv...@gmail.com wrote: Perhaps you're looking for fixtures? http://thornydev.blogspot.co.uk/2012/09/before-and-after-logic-in-clojuretest.html U On 21 May 2013 15:17, Colin Yates colin.ya...@gmail.com wrote: Howdy, I am using clojure.test and have some questions of how to write idiomatic Clojure. This really isn't about testing at all per-se. First - I know about fixtures to get (at least) the same as JUnit's before/after behaviour. My code is a bloomy. You can configure the bloomy and it does different things based on that behaviour. Pretty much every test has a different bloomy, *and* that bloomy must be elegantly shut down. How should I handle this? At the moment I have the most un-idiomatic way and blunt way of : [code] (deftest my-test (let [bloomy (create-a-bloomy] (try (do-something-with-my-bloomy) (is (=)) (finally (shut-down bloomy [/code] Yep, try/finally in every test - reminds me of early JDBC libraries before Spring :). If I understand it correctly, I would end up writing a separate fixture for each and every test, or at least each any every unique set of test context. I did consider writing a (defn with-bloomy [bloomy test] (try (test) (finally (shut-down bloomy but I couldn't figure out how to pass my bloomy into the test itself. I also received lots of assertion not in expectation type errors. To be explicit I would use this as (with-bloomy (create-a-bloomy) (deftest...))). I did consider a variation on the above of passing in a function which only contained the assertions, so (deftest my-test (let [bloomy...] (with-bloomy bloomy #(is (= 1 (get-something bloomy) but I also ran into similar assertion not in expectation type errors, and the indentation in emacs was insane. I expect a macro might be the answer? So, how would you solve 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to a topic in the Google Groups Clojure group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/Pm-DUDxWeM4/unsubscribe?hl=en. To unsubscribe from this group and all its topics, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient
Re: Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom
Does the projects look like the work of someone that is an utter moron ... your response certainly is. On Thu, May 2, 2013 at 10:28 AM, Jay Fields j...@jayfields.com wrote: On Thursday, May 2, 2013 10:19:51 AM UTC-4, David Toomey wrote: [snipped] If you want help in the future, I'd recommend spending less time demanding answers and more time reading responses and code. I've never looked at the 4clojure source, didn't even know it was on github. I've never used ring, compojure, or any other clojure web framework. The total time it took me to clone the 4clojure repo, grep for what John recommended, and get you this link ( https://github.com/4clojure/4clojure/blob/develop/src/foreclojure/core.clj#L58), about 30 seconds. Python has been around significantly longer, and has a much larger community. If you need that level of support, I don't think Clojure is the right language for you. Cheers, Jay -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Do functions never get inlined by jvm?
There seems to be some rule that given sufficient time and enough participants, all threads deteriorate into an argument about the current state of clojure documentation and a huge post from Tim Daly regarding literate programming in 3...2...1... On Thu, Apr 25, 2013 at 2:23 PM, Gary Trakhman gary.trakh...@gmail.comwrote: Good vinyls are considered higher quality by audiophiles, because there are less stages in between the mastering and amplification. There is more potential of better performance. It can be considered a real-world case of inlining. On Thu, Apr 25, 2013 at 3:16 PM, Softaddicts lprefonta...@softaddicts.cawrote: May I suggest you an upgrade ? http://www.ehow.com/how_6949396_record-78-vinyl-records-cd.html 2013/4/25 Softaddicts lprefonta...@softaddicts.ca Of course my answer comes in total antagonism with your usual position about the bad state of the existing documentation which is incomplete, wrong, ... and so forth. Your reaction does not suprise me, your behavior is quite predictable. Like an old vinyl record with all these scratches being played over and over again. Nothing has changed w.r.t. Clojure/core's attitude towards documentation and making it easy for other people to contribute documentation improvements that are rapidly integrated instead of gathering dust in JIRA for many months. Why would I suddenly start singing praises to something that is broken and does not change? Sorry pal, someone has to periodically remind those in control of Clojure that we are exactly where we were years ago. And that the entire community has to put up with this. Definline may be tagged as experimental but defrecord, defprotocol, ... are marked as being in alpha stage. Does this prevents you from using them ? Those are mentioned in every book and are widely used. It would be crazy to break those by now. Makes a bit of difference when it comes to recommending features to people, don't you think? -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Softaddictslprefonta...@softaddicts.ca sent by ibisMail from my ipad! -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to
Re: Clojure/West 2013 videos?
I'm starting to miss Ken Wesson. On Mon, Mar 25, 2013 at 4:08 PM, Gary Trakhman gary.trakh...@gmail.comwrote: I've volunteered on the pycon AV team, in 2009, it's 1000x more work than what you described further up in the thread, a minimum wage worker holding something steady. It requires a lot of coordination, and I think the cost to the conference would be much higher than InfoQ as well. On Monday, March 25, 2013 1:05:51 PM UTC-4, Cedric Greevey wrote: On Mon, Mar 25, 2013 at 12:41 PM, Michael Klishin michael@gmail.comwrote: 2013/3/25 Cedric Greevey cgre...@gmail.com Don't forget that Youtube has MILLIONS of visitors per month. Imagine the impact if the videos were available when demand for them was actually at its peak, rather than after half the people that had been interested have forgotten all about them. I challenge you to put together a technical videos channel that has millions of visitors per month. Another minute, another straw man. My point is that the needed video hosting capability already exists (and even has monetize options). Of *course* it will be expensive to go the reinvent all needed wheels route. I don't get it. The thread got complaints that the videos were being produced slowly and inefficiently, yet as soon as someone actually suggested ways to potentially make the process faster and more efficient, practically *everyone* leapt to the defense of those same slow and inefficient methods that they'd previously complained about. I guess abstract kvetching is okay, but concrete suggestions are frightening because they might *actually lead to change* or something. Although that still doesn't explain why someone then had the gall to criticize *me* for not making concrete and constructive suggestions, when that's exactly what I *did* do after *other people* had merely complained without making any suggestions. Of course, I don't really *need* to argue anymore, because someone else helpfully pointed out that an existing conference already does a better job: pycon. That completely disproves the entire class of arguments along the lines of making *conference proceedings* videos is somehow some sort of a special case and it HAS to be slow and expensive!, of which we've seen several, sadly including some *after* pycon was first mentioned. -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Find union of nodes with data.zip
Looking at the source of clojure.data.zip, it looks like something like: (xml- x :a (seq-test [(tag= :b1) (tag= :b3)]) :c) (untested) might work? http://clojure.github.com/data.zip/ On Mon, Nov 5, 2012 at 10:38 AM, Stefan Kamphausen ska2...@gmail.com wrote: Hi, AFAIK the currently supposed way of parsing XML with Clojure is to use a combination of clojure.xml, clojure.zip, data.zip and data.zip.xml. Please correct me if I'm wrong. I am trying to extract the equivalent of a union of nodesets from an XML file (speaking in XPath terms). Example: input.xml: root a b1 cC1/c cC2/c /b1 b2 cC3/c cC4/c /b2 b3 cC5/c cC6/c /b3 /a /root Suppose I have an array (or whatever) with the allowed b-tags, e.g. b1 and b3. Now I want to extract all c-tags underneath b1 and b3 but skip those under b2. Using clojure.xml/parse, clojure.zip/xml-zip and data.zip.xml/xml- I can easily extract certain nodes but I have not found a way to extract such a union, yet. A rather lispy approach would be using or in a manner similar to this: (def x (clojure.zip/xml-zip (clojure.xml/parse /path/to/input.xml))) (clojure.data.zip.xml/xml- x :a (or :b1 :b3) :c) And I did not yet understand how to write my own predicates there. Any pointers? Kind regards, stefan -- 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: Find union of nodes with data.zip
you're right, my bad. should have read it more carefully :) On Mon, Nov 5, 2012 at 2:32 PM, Stefan Kamphausen ska2...@gmail.com wrote: Hi, if I am doing this right, then your supposed approach does not work. From looking at the code of seq-test (to which the alternative form using just a vector in xml- boils down, too) it seems to be more like a look ahead within the current node. See e.g. the test code at https://github.com/clojure/data.zip/blob/master/src/test/clojure/clojure/data/zip/xml_test.clj#L45 (I can't claim to fully grok mapcat-chain in zip.clj, though.) Regards, stefan -- 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: Documenting clojure data structures
you could try using contracts to specify what keys are supposed to be in the map, or just use pre/post conditions built in to clojure? https://github.com/fogus/trammel On Wed, Oct 31, 2012 at 1:01 PM, Jason Bennett jaso...@gmail.com wrote: Over the last month, I've been learning clojure for my new job, and taking Odersky's scala course on coursera. I've been enjoying my time with clojure much more, but the one thing I miss from scala is the ability to document a data structure. It's really nice in Java/Scala to type in an object and get a list of methods/members that are available, instead of having to trace the code and/or guess. I've seen things in clojure like defrecord, but have not seen good examples of if this is a good way to give some structure to my data. I don't want to turn clojure into an OO language, but there are times when I'm passing around a large map that it would be nice to be able to know what to expect. jason -- 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: Fail to run dynamic binding code with Clojure1.4
As of Clojure 1.3 you need to mark things you with to re-bind explicitly as dynamic: (defn ^:dynamic twice [x] ...) On Tue, Oct 30, 2012 at 7:42 PM, Satoru Logic satorulo...@gmail.com wrote: Hi, all. I am reading Clojure in Action. In the scope section of Chapter3, there are examples like this: defn twice [x] (println original function) (* 2 x)) (defn call-twice [y] (twice y)) (defn with-log [function-to-call log-statement] (fn [ args] (println log-statement) (apply function-to-call args))) (call-twice 10) (binding [twice (with-log twice Calling the twice function)] (call-twice 20)) (call-twice 30) When I tried to run this code in repl, I got the following exception: IllegalStateException Can't dynamically bind non-dynamic var: user/twice clojure.lang.Var.pushThreadBindings (Var.java:353) Is the book wrong or I'm running with the wrong version of clojure? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: compile fails but stack trace does not mention a line of code in my app
Look in who-is-logged-in.core for errors On Thu, Oct 25, 2012 at 1:36 PM, larry google groups lawrencecloj...@gmail.com wrote: who-is-logged-in.core -- 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 expectations-mode 0.0.3
Hi, expectations-mode is an Emacs mode for running tests written using the expectations library: https://github.com/jaycfields/expectations. I have just released expectations-mode 0.0.3 which now runs under nrepl (no longer supports swank-clojure). It is in marmalade: http://marmalade-repo.org/packages/expectations-mode, and the repo lives here: https://github.com/gar3thjon3s/expectations-mode. If you use swank-clojure, stick with 0.0.2! Congrats to the maintainers of nrepl.el, it was very easy to convert over to use it :) Thanks, Gareth -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN clojure-doc.org (aka CDS), a new community-driven Clojure documentation site
I have 3 blog posts I wrote to help some colleagues get up to speed with clojure / emacs: http://blog.gaz-jones.com/2012/02/01/setting_up_emacs_for_clojure_development.html http://blog.gaz-jones.com/2012/02/02/clojure_development_cycle.html http://blog.gaz-jones.com/2012/02/03/clojure_command_line_apps.html They are all based on Emacs 24, leiningen 1.x, and swank-clojure. Is there any appetite for me to convert / update them and merge them into CDS under the tutorials section? I have been told by a few people that they found them useful and I tried but failed to find anything similar elsewhere on the interwebs (particularly the clojure development cycle one). Gaz On Thu, Oct 11, 2012 at 9:32 AM, Michael Klishin michael.s.klis...@gmail.com wrote: 2012/10/11 Laurent PETIT laurent.pe...@gmail.com What clojure/dev could do (if it's not already possible) is make deltas of changes made to clojure.org ridiculously easy to track from the outside. If keeping clojure.org content in a git repository is not possible, then notify this list. -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN clojure-doc.org (aka CDS), a new community-driven Clojure documentation site
Alright, I'll convert the appropriate ones and send you a pull request when I'm done. I'm happy to pick up writing a tools.cli tutorial too when I get some spare time. Thanks for kickstarting the effort, it's shaping up to be a great resource. -- 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: understanding 'binding' use in clojure.java.jdbc
Yeah, you probably shouldn't rely on this but I think it will still work. I have done something similar before when reading from 3 databases simultaneously (3 nested with-connection and with-query-result calls) and I believe (connection) is only called once when creating the prepared statement. On Tue, Oct 9, 2012 at 9:24 PM, Sean Corfield seancorfi...@gmail.com wrote: No, the inner with-connection binds *db* to db1 so db2 is no longer accessible. This is why c.j.jdbc is getting an API overall that will expose functions that accept the connection or the db-spec directly (and the old API will be rewritten in terms of the new one for compatibility). Sean On Tue, Oct 9, 2012 at 2:44 PM, gaz jones gareth.e.jo...@gmail.com wrote: Can you not simply: (jdbc/with-connection db2 (jdbc/with-query-results results query {:result-type :forward-only :fetch-size 1000} (jdbc/with-connection db1 ;; read and write? ))) ? -- 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: understanding 'binding' use in clojure.java.jdbc
Can you not simply: (jdbc/with-connection db2 (jdbc/with-query-results results query {:result-type :forward-only :fetch-size 1000} (jdbc/with-connection db1 ;; read and write? ))) ? On Tue, Oct 9, 2012 at 2:53 PM, Brian Craft craft.br...@gmail.com wrote: On Tuesday, October 9, 2012 12:11:28 PM UTC-7, Tassilo Horn wrote: Brian Craft craft...@gmail.com writes: Hi Brian, If (read-stuff) is not lazy, then this looks pretty simple: all the data is loaded in memory returned to (write-stuff). If the data is large you wouldn't want it all in memory. What then? Could you make read-stuff return a lazy sequence? My impression after a brief experiment is that this doesn't work: when the inner with-connection* returns, the db connection is closed. A lazy sequence from (read-stuff) then can't be evaluated w/o throwing an error. Yes, that's true. Maybe Korma [1] is better suited for this kind of operation. Damn. I was hoping there was some lispy fp thing I was missing here, but *db* really is just a global variable that fails in the same way that globals fail in all languages. Thanks for the link to korma. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: a Clojure docs site, and github organization
While on this topic, is it possible for someone with admin privileges to disable the Issues tabs in the contrib projects? There is a consistent drip of people sending pull requests or opening bugs which have to be redirected to JIRA. All of the contrib projects now point to JIRA in the README for both these things. On Sun, Oct 7, 2012 at 2:40 AM, nchurch nchubr...@gmail.com wrote: Just to keep in touch with our marvelous legal systems in North America, read this: ... how much I am frustrated by this shattered world Indeed! The law is nothing but an overly complex, haphazardly designed, historically encrufted programming language for morals. Its compiler is frighteningly well-maintained, though. On Oct 6, 6:24 pm, Softaddicts lprefonta...@softaddicts.ca wrote: It works for Oracle because they have the $$$ to support it. You just confirmed that we are on the same wavelength, they have the weapons to nail anyone who would like to exercise exclusive rights on some contribution made under their CA even if that individual lives in Kazakhstan. They have the infra structure and several offices in various Countries and continents to cover their ass. Just to keep in touch with our marvelous legal systems in North America, read this: http://hrdailyadvisor.blr.com/archive/2010/08/20/Epinions_Employment_... The first question/answer is pretty instructive. It's easier to avoid the whole issue with a piece of paper. Maybe in ten years things will have settled somehow. The above is dated from 2010 that's not far away. I will not anything else to this thread, the world is as it is. I you think that you are frustrated, maybe we should have a drink together and I could explain how much I am frustrated by this shattered world Do you expect to drop at the Conj ? Luc 2012/10/7 Softaddicts lprefonta...@softaddicts.ca The validity of a scanned signature or electronic keys is subject to interpretation and assessment on a per case basis especially in civil contracts by the diverse legal systems on Earth. It's not the Clojure community that is behind, it's the legal systems of many countries that did not follow the pace of technology. Some will not recognize scanned signatures at all. On the other hand, original hand written signatures are recognized almost every where. A reminder: scans work for Oracle and ASF. Oracle probably has x100 as many lawyers as Clojure/core, lawyers several times as experienced and about x10,000 times as much experience with this stuff as a company. And it works for them. As much as you complain about the paper CA, you should complain about the legal systems of these countries that do not follow US and western Europe attempts to recognize technology changes and adapt to it. You analyze the issue by the wrong end It's not a technology issue, it's a legal one. You could have the best electronic authentication scheme, if it's not recognized by a country's legal system, it's useless in court in this country. If claims rights on contributions not backed by a CA in a valid form as defined in this country, it's a lost case. Big organizations have the tools and budgets to fight in various legal systems out there. Not small open source projects or projects without big sponsors. I understand and approve the requirement of the original hand written signature in this context. That's a real life issue that cannot be dealt with by technology alone. If a national mail system is not able to get reliably an envelope to the US within 4/5 weeks, I would be very concerned about the state of their legal system. Sorry to break it to you, but legal systems outside of a few countries are seriously broken and it will take decades and many lives to fix this. And I assure you, people who live in those countries are just as concerned as you are, thanks for caring. So the system is how it is. Clojure/core can accept this unfortunate fact and find a way to accept CA submissions electronically. Or they can ignore all the complaints (again, not about the CA per se, but how it is currently submitted) and lose many potential contributions. Contributions from people who really want to make Clojure better, ready to spend many hours of their time contributing but were not lucky enough to be born in the Wonderland called Canada, where the law rules and the sun shines (at least 2 months of the year). It always starts with contributing something small. Then something else small. Then something slightly more significant. And next thing you know, you are a major contributor. That's how it started for every single active OSS contributor I know. -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- You received this message because you are subscribed to the Google
Re: Handling exceptions (subject renamed)
http://clojure.github.com/clojure/clojure.stacktrace-api.html On Fri, Oct 5, 2012 at 12:06 PM, Matt ma...@cloudaloe.org wrote: Hi, Sorry to anyone who read the original post. Apparently I had malformed the try block encompassing the create-table in a very non-clojure-ish way. So my problem wasn't with clojure.java.jdbc's create-table. Being 'dynamic', clojure could not warn me about it until it crashes in runtime. I guess I should also learn more about making exception printouts contain more details (such as line number as one, if that's at all possible?) I'd appreciate knowing how to get more details when an exception is caught by my code e.g. at least a line number if possible - I was using - (catch Exception e (println (str Exception is: e))) Which only yielded a general description (java.lang.ClassCastException: clojure.lang.ArraySeq$ArraySeq_int cannot be cast to clojure.lang.IFn) without indicating where my code broke. Is it possible to get the source line that made the code break? Thanks! On Friday, October 5, 2012 5:15:18 PM UTC+2, Matt wrote: Hi, I'm relatively new to Clojure. This must be easy. I am trying to write a function that creates a table with a name passed as argument, and this naturally requires passing clojure.java.jdbc/create-table a value for the table name, rather than specifying the name as a constant. However I'm not insofar able to pull it off. When I use the form create-table passed-argument [fields] as opposed to a constant as in create-table :hard-coded-entity-name [fields], then the table gets successfully created in the database, however my code also gets an exception - java.lang.ClassCastException: clojure.lang.ArraySeq$ArraySeq_int cannot be cast to clojure.lang.IFn. The exception is received even though the table had been seemingly perfectly created. I'm probably missing something basic. What do you think can it be? Thanks, Matt -- 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: Noir.response and custom java object
It seems to be using cheshire under the covers, did you add an encoder for your class? e.g: (add-encoder java.awt.Color (fn [c jsonGenerator] (.writeString jsonGenerator (str c On Thu, Oct 4, 2012 at 12:04 PM, arekanderu arekand...@gmail.com wrote: Hello, I am not sure if i am supposed to ask a noir-related question in the group but the noir issues at github is closed so i thought someone here might know. I am trying to use a custom encoder with noir.response but i am failing to understand how. This is what I am trying to do which at the moment fails of course: (ns my-app.views.my-page (:require [noir.response :as resp])) (defpage /my-page [] (let [java-object (do-something)] (resp/json java-object))) The error message Cannot JSON encode object of class: class-name-here - (class org.codehaus.jackson.JsonGenerationException) It does work however if i use gson on my java-object before i pass it to resp/json but i prefer to do it without gson. I am pretty sure its possible :) Thank you for any replies -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure web framework
You do not need noir to create a simple json api, just use compojure. I find the Cheshire json library to also be useful: https://github.com/dakrone/cheshire. Authentication and authorization libs were pretty much up to you until https://github.com/cemerick/friend was released fairly recently, so you could look at that (I haven't used it myself). I would also recommend starting the server with embedded jetty rather than mess around with app containers, it's far simpler (look at ring.adapter.jetty). We have many json apis written in clojure in production where I work, and they have worked out great for us. On Wed, Oct 3, 2012 at 1:01 PM, arekanderu arekand...@gmail.com wrote: Hello, I had a similar question as the OP so I thought i should post it in this thread instead of starting a new one. I am trying to build a web services api which will only respond in json format. I had a look at everything suggested in this topic and I am leaning towards noir. Do you think this would be a good option for a web services api or should i go with ring + compojure, or something else?? In addition, I will be needing to add authentication and authorization at the api and I haven't found a noir middleware to be able to handle this. Do I need to roll out something of my own with the use of noir pre-route and maybe a middleware or is there something in existence which I am not aware of? Thank you for any replies. On Friday, September 28, 2012 10:36:20 AM UTC+3, Yakovlev Roman wrote: Hi So i'd like to point to the problem here. Clojure web framework in google get these results, at least for me 1. noir 2. stackoverflow question 2008 year 3. stackoverflow question 2010 year 4. joodo ( outdated thing developed by one person) 5. Compojure ( routing dsl) So there is no popular framework these days for clojure. Noir is mostly Chris Granger thing. As he make Lighttable today Noir developed by some other people ( or may be on person not sure). Main site instructions are nice but already outdated ( lein2). No news, no blog, no new features, no examples, no infrastructure. Lein new project, insert noir in dependencies and you don't have working app, you must add :main and stuff to work. What about testing ? no info, no structure, decide on your own. It's no secret that web development today is biggest and popular trend. If language and it's community have good web framework that language will gain more popularity. Take Ruby on rails it has over 30 core contributers, huuuge community, active development, industry standart web development framework. Good testing, development infrastracture, easy start, sprockets for js css managment and so on. Also it has some books about testing and framework itself which is good start point for newbies. I like Clojure, for simplicity mostly. It has amazing power and i believe it can be very good platform for web development. So what i suggest : Take 1 platform for web development in Clojure (for example noir as most mature framework) . Form working core group from 5-6 people. Decide about name of the project ( or take Noir) Make good site about it Make a plan for development ( what core features should have first version) Make first version Make couple good examples Make good documentation and maybe a book ( community book for example on github that will be online and updated frequently). -- http://www.playframework.org/ good example what site could be Alternative to online book can be guides, as for ruby on rails http://guides.rubyonrails.org/index.html Another good news that there is nice web IDE for Clojure by Bodil Stokke https://github.com/bodil/catnip. Super easy install, very nice insterface, reactive interface ( no need for browser refresh, autorecompile when you save ) web based ! and under active development, just perfect place for newbies to start. So this project also can be added to Clojure Web framework project. Also we have ClojureScript so Clojure web framework would be perfect place where this thing can shine. Let's discuss. -- 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: Transforming an ugly nested loop into clojure code
You appear to be running over the map purely for side-effects, therefore off the top of my head something like: (defn my-func [data] (doseq [area data warehouse (:warehouses area) container (:containers warehouse) box (:boxes container)] (if-not (empty? (:items box)) (doseq [item (:items box)] (do-something (:box box) (:item item))) (do-something-else (:warehouse warehouse) (:container container) (:box box) Might be more appropriate... On Mon, Oct 1, 2012 at 5:07 PM, arekanderu arekand...@gmail.com wrote: (def my-data [{:area Somewhere :warehouses [{:warehouse W54321 :containers [{:container C12345 :boxes [{:box B12345 :items [{:item I12345}]}]}]}]} {:area SomewhereElse :warehouses [{:warehouse W54321 :containers [{:container C54321 :boxes [{:box B54321 :items [{:item I54321}]}]}]}]}]) (defn my-func [data] (map (fn [area] (map (fn [warehouse] (map (fn [container] (map (fn [box] (if (not (empty? (:items box))) (map (fn [item] (doSomething (:box box) (:item item))) (:items box)) (doSomethingElse (:warehouse warehouse) (:container container) (:box box (:boxes container))) (:containers warehouse))) (:warehouses area))) data)) -- 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: how do I evaluate this lazy sequence?
Couple of initial things, Clojure has immutable data structures so when you call for example 'assoc' it will return you a new map with the new values assoc'd. It will not mutate the original, so: (let [foo {}] (assoc foo :a 1) (assoc foo :b 2) foo) Will return {}. You need to do something like: (- {} (assoc :a 1) (assoc :b 2)) = {:a 1 :b 2} FYI, assoc takes multiple kvps: (assoc {} :a 1 :b 2) Also, to return valid JSON, you cannot simply call 'str' on the map. You need to use a library like https://github.com/dakrone/cheshire or https://github.com/clojure/data.json and encode the map as JSON. Perhaps you could illustrate the data structure you are holding inside of @registry, and the structure of the JSON you would like to emit. Laziness is not an issue here. On Thu, Sep 27, 2012 at 12:02 PM, larry google groups lawrencecloj...@gmail.com wrote: I would like 2 types of advice: 1.) an answer to this specific question 2.) advice on how one is suppose to debug mysteries likes this I have a simple web app that serves some data (hopefully in JSON format, but at the moment I will accept anything at all). The app uses Ring and Moustache and outputs the data. We start with a simple atom: (def registry (atom {})) We put some data in this atom. And then we output it. But I have had great difficulty getting anything to appear on the screen. Assuming the problem was with the fact the main sequence was lazy, I added in doall everywhere it made sense. But I still can not get anything to work: (defn current-users [request] The default action of this app. Add new users to the registry, and delete the ones that are more than 15 seconds old (let [this-users-params (:params request) final-map-for-output {}] (add-to-logged-in-registry this-users-params) (remove-old-registrants) (response (apply str (into {} (doall (map (fn [each-user-map] (doall (let [inner-details (second each- user-map)] (assoc final-map-for-output username (get inner-details username nothing found for user)) (assoc final-map-for-output updated (get inner-details updated nothing found for updated)) final-map-for-output))) @registry))) The various variations I have tried on this have either given me a blank white page or: {} Nothing else. I used to do simply: (response (apply str (doall @registry) This worked fine. But it did not output valid JSON, so I wanted to change the format. But I have not been able to get anything to appear on screen. Suggestions? -- 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: JSON serialization with unknown types
you might find this useful: https://github.com/dakrone/cheshire you can pretty much swap it in for data.json IIRC and it has nice support for custom encodings, amongst other things. On Wed, Sep 26, 2012 at 12:39 PM, Robert Beaupre codewise.rob...@gmail.com wrote: Hi there, I am wondering what the best/recommended way to deal with serialization of unknown types to JSON with clojure.data.json. For things like UUIDs and SQL Dates, I get errors like this: java.lang.Exception: Don't know how to write JSON of class java.util.UUID With Clojure 1.4 is there an extensible way of doing this or should I make a wrapper function that converts unknown types to strings and then call json-str on the data structure? Thanks, Robert -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question: Looking at Noir code - hey, are those singletons?
I find myself having to make similar choices quite often in my own Clojure code - do I create perhaps a map of things that represent some kind of 'state' and pass that around to each function that needs it, or do I do what has been done above and create some vars in a ns where most (all?) the functions that use this data live. I think either can be the right choice in different circumstances. For example, I always store configuration data in a var that has a few functions using it rather than passing a config map to every function in the application that needs access to it. I just use those functions throughout the codebase instead. I'm not at all familiar with noir so cannot answer your question regarding that specifically, but I would say using your own judgement is a Clojure best practice :) On Wed, Sep 12, 2012 at 9:30 AM, the80srobot a...@ingenious.cz wrote: Is this a Clojure best practice? -- 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: Lazy sequences to replace looping?
You may find this useful: http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/ loop-recur might be the best way to do it. On Tue, Sep 11, 2012 at 11:16 PM, Geo ggrigor...@gmail.com wrote: Hello, I am just getting started with Clojure and I had a question. I have to following code: (get-rss-entry (get-rss-feeds h-res) url) The call to get-rss-feeds returns a lazy sequence of URLs of feeds that I need to examine. The call to get-rss-entry looks for a particular entry (whose :link field matches the second argument of get-rss-entry). It examines, one-by-one, the lazy sequence returned by get-rss-feeds. Evaluate each item requires an http request across the network to fetch a new rss feed. Therefore, to minimize the number of http requests it's important to examine the sequence one-by-one and stop as soon as there is a match. Here is the code: (defn get-rss-entry [feeds url] (first (drop-while empty? (map #(entry-with-url % url) feeds entry-with-url returns a lazy sequence of matches or an empty sequence if there is no match. First, I want to make sure I understood lazy evaluation correctly and that I did this right. I tested this and it seems to work correctly. Second, not sure if I am solving this problem idiomatically. In Java, for example, this would likely be solved with a loop examining some data structure. At first I did it with a loop/recur but that didn't seem like the right way to do it. Also I saw somewhere that looping in considered low level in Clojure or something to that effect. I would appreciate your feedback. Thanks for your help. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: Routing HTTP/ JSON in clojure
We do all of the things you mention (minus the replay, but that would be trivial) in Clojure where I work, and it is remarkably easy. We use: * ring + compojure and an embedded jetty server to create lightweight webservers * the Cheshire JSON encoding/decoding library for all JSON purposes (https://github.com/dakrone/cheshire) * we wrote our own small wrapper around rabbitmq - but there are several available now (such as https://github.com/michaelklishin/langohr) * for mongo we use: http://clojuremongodb.info/ We also found that when processing JSON messages, multimethods can be extremely useful as a dispatch mechanism if the shape of the JSON data dictates what should happen to it. I would certainly recommend Clojure for what you describe, I think you will be pleasantly suprised how straightforward it is :) On Tue, Sep 4, 2012 at 7:05 PM, Russell Whitaker russell.whita...@gmail.com wrote: On Tue, Sep 4, 2012 at 4:45 PM, David Dawson david.daw...@dawsonsystems.com wrote: Hiya! I saw the names, but then was swamped by moustache, noir and others that at first glance appear to be in similar spaces. I found it a bit difficult to pick out the various specialisms or layers each library is aiming at tbh. So, I thought it best to look for some guidance if possible from people who know what they're doing ... :-) Some of us are only ahead of you by relative measures: I myself had to _remove_ noir noir-async from a project today because of some reloading issues introduced by the latter; see today's (4 Sep 2012) clojure IRC log: http://clojure-log.n01se.net/ Russell david On Wednesday, 5 September 2012 00:24:46 UTC+1, Russell Whitaker wrote: On Tue, Sep 4, 2012 at 1:52 PM, David Dawson david@dawsonsystems.com wrote: Hiya, So, I'm a clojure newbie... and I've been asked to evaluate a few different technology options for a project I've been handed. The end result will need to be a 'router' that accepts JSON messages over HTTP, store them into some datastore (ideally one of the ones available on cloudfoundry, postgres mongo etc), then forward the message onto one or more end points. Forwarding will probably be either dropping into rabbitmq or posting on with HTTP. (or both). There also needs to be a replay capability, so you can tell the router to scoop up the historical messages from the datastore and forward them all on (in order) to a particular end point. I'm totally open to any tech, prebuilt (and commercial) or development required but given that the system needs some algorithmic routing rules, clojure seemed a really nice conceptual fit over the languages I normally work with (imperative jvm ones, essentially) So, I'm really interested in any suggestions on how this might best be approached in the clojure world! Hi David, have you looked at Ring + Compojure? -- Russell Whitaker http://twitter.com/OrthoNormalRuss / http://orthonormalruss.blogspot.com/ http://www.linkedin.com/pub/russell-whitaker/0/b86/329 -- 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 -- Russell Whitaker http://twitter.com/OrthoNormalRuss / http://orthonormalruss.blogspot.com/ http://www.linkedin.com/pub/russell-whitaker/0/b86/329 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure.org/getting_started: not up to date
I've been playing with Go a lot recently, and I have found the documentation / new user experience very good: http://golang.org/ On Mon, Sep 3, 2012 at 2:19 PM, Denis Labaye denis.lab...@gmail.com wrote: On Mon, Sep 3, 2012 at 5:40 PM, Softaddicts lprefonta...@softaddicts.ca wrote: Btwy, using leiningen's repl hides all these issues... yes, and Emacs is one of the best for hacking Clojure code ... But not necessarily for new users, who don't know Emacs or Java. And even better than lein: You can't beat an online REPL for a quick Clojure experience, like http://tryclj.com/ It would be cool if an online REPL was available just on the front page of clojure.org Luc This will work only if A) there is a manifest in the jar specifying which class contains the main method B) if you do not need to add libraries explicitly, -cp is ignored when you use -jar Clojure.org is correct, especially regarding b). If you happen to need to add libs to your REPL, -jar is a dead end. If you happen to create a specific main for your own app, using -jar is much more complex to setup. Luc P On http://clojure.org/getting_started: Download http://clojure.org/downloads and unzip Clojure. In the directory in which you expanded clojure.zip, run: java -cp clojure-1.4.0.jar clojure.main Should be just: java -jar clojure-1.4.0.jar It's a detail, but an important one, as it's the first contact for most of the new Clojure users. Denis On Mon, Sep 3, 2012 at 9:00 AM, Denis Labaye denis.lab...@gmail.com wrote: 1. java -cp ./org/clojure/clojure/1.4.0/clojure-1.4.0.jar clojure.main 2. cut paste your code in the REPL 3. type (start) [enter] On Fri, Aug 31, 2012 at 3:36 AM, gearss gearss8...@gmail.com wrote: I have a file named pong.clj, it isunder following, I want to know how can I run it? Thank you. (ns example.game.pong (:use [penumbra opengl] [clojure.contrib.def]) (:require [penumbra [app :as app] [text :as text]])) (def ball-width 0.03) (def ball-height 0.03) (def paddle-width 0.02) (def paddle-height 0.15) ;;; (defn abs [x] (Math/abs x)) (defn intersect-1d [[a b] [x y]] (and (= a y) (= b x))) (defn intersect-2d [[a b c d] [x y z w]] (and (intersect-1d [a c] [x z]) (intersect-1d [b d] [y w]))) (defn reflector [[x y w h] f] (let [r [x y (+ x w) (+ y h)]] (fn [region velocity] (if (intersect-2d region r) (f velocity) velocity (defvar boundaries [(reflector [0 -1 1 1] (fn [[x y]] [x (abs y)])) (reflector [0 1 1 1] (fn [[x y]] [x (- (abs y))])) (reflector [-1 0 1 1] (fn [[x y]] [(abs x) y])) (reflector [1 0 1 1] (fn [[x y]] [(- (abs x)) y]))]) (defn update-ball [state dt] (let [ball (concat (:p state) (map + (:p state) [ball-width ball-height])) v (reduce #(%2 ball %1) (:v state) (conj boundaries (reflector [0.01 (:left state) paddle-width paddle-height] (fn [[x y]] [(abs x) y])) (reflector [(- 0.99 paddle-width) (:right state) paddle-width paddle-height] (fn [[x y]] [(- (abs x)) y]] (assoc state :v v :p (map + (:p state) (map (partial * dt) v) (defn draw-ball [pos] (push-matrix (apply translate pos) (draw-quads (vertex 0 0) (vertex ball-width 0) (vertex ball-width ball-height) (vertex 0 ball-height ;;; (defn update-opponent-paddle [state] (let [[x y] (:p state) [vx vy] (:v state) dt (/ (- 1 x) vx) dy (- (+ y (* vy dt)) (:right state))] (assoc state :v-right (if (neg? vx) 0 (/ dy dt) (defn update-player-paddle [state] (assoc state :v-left (cond (app/key-pressed? :up) -1 (app/key-pressed? :down) 1 :else 0))) (defn update-paddle [dt v pos] (min (- 1 paddle-height) (max 0 (+ pos (* dt v) (defn draw-paddle [x y] (push-matrix (translate x y) (draw-quads (vertex 0 0) (vertex paddle-width 0) (vertex paddle-width paddle-height) (vertex 0 paddle-height ;;; (defn reset-game [state] (assoc state :v [0.4 0.8] :p [0.5 0.5] :left 0.5, :v-left 0.0 :right 0.5, :v-right 0.0)) (defn init [state] (app/vsync! true) (app/title! Pong) (app/periodic-update! 2 update-opponent-paddle) (reset-game state)) (defn reshape [[x y w h] state] (ortho-view 0 1 1 0 -1 1) state) (defn update [[delta _] state] (- state
Re: Origin of tools.cli optional
The library was originally based on Clargon (a library I wrote) which had the interface you are describing (optional and required functions). Various changes were made after getting feedback on the clojure-dev mailing list, which you can read about here if you're interested: https://groups.google.com/d/topic/clojure-dev/KGvzndhX5vk/discussion Hopefully the project documentation is clear about its use: https://github.com/clojure/tools.cli Hope that helps, Gaz On Fri, Aug 24, 2012 at 2:52 PM, octopusgrabbus octopusgrab...@gmail.com wrote: Given the following code (defn parse-opts Using the newer cli library, parses command line args. [args] (cli args (optional [--in-file-name .csv input file :default resultset.csv] identity) (optional [--out-file-name .csv pipe delimited output file :default accumail_out.unl] ))) What is the origin of optional, and why do tools.cli examples that I can find now leave out (optional ... ? Would current examples still use identity? Here is why I'm asking: http://stackoverflow.com/questions/12112403/how-do-i-mix-non-optional-cli-arguments-with-optional-ones Thanks for any pointers or help. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: A succinct reasonably fast sudoku solver in core.logic
Wow, that's pretty nice. On Tue, Jul 31, 2012 at 8:07 AM, David Nolen dnolen.li...@gmail.com wrote: Ever since I read Norvig's cool Python solution, http://norvig.com/sudoku.html, I've been wanting to see if this could be done in core.logic without sacrificing generality. Now that we have cKanren extensions in master I gave it a shot (thanks to Martin Trojer) and I'm happy with the results. http://dosync.posterous.com/sudoku I think this example illustrates how powerful it can be to use functional programming to drive a logic program. David -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: is their a Clojure framework for handling form validation?
https://github.com/mikejones/mississippi again, not specific to web forms. works on clojure maps and is extensible. On Sun, Jul 22, 2012 at 6:46 PM, larry google groups lawrencecloj...@gmail.com wrote: Since 2000 I've been doing web development, first with PHP and then with Ruby On Rails. In the world of PHP, there are some frameworks, such as Symfony, that have classes for managing forms, both generating the HTML for the forms, and also handling the validation of the forms. In the world of Python, the Django framework also has facilities for generating and validating forms. These frameworks offer certain time saving conveniences. For instance, with the Symfony framework, if you have a database table that has a foreign key, then you can get that other table (the target of the foreign key) to appear in a form as a pre-populated select box, automatically (after filling out some config files). I'm now trying to make Clojure my primary development language for everything, including web development. I'm curious, are there any libraries in the land of Clojure that offer similar conveniences for forms? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: ClojureScript Synonyms
this page is amazing: http://himera.herokuapp.com/synonym.html this should be part of the standard docs for clojurescript - or am i just blind and cannot find it? it would have saved me so much time *sob* On Mon, Apr 23, 2012 at 3:45 PM, David Nolen dnolen.li...@gmail.com wrote: http://himera.herokuapp.com/synonym.html -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: ClojureScript Synonyms
cheers! :D On Mon, Apr 23, 2012 at 4:20 PM, David Nolen dnolen.li...@gmail.com wrote: I've added links to Himera in the ClojureScript GitHub README On Mon, Apr 23, 2012 at 5:18 PM, gaz jones gareth.e.jo...@gmail.com wrote: this page is amazing: http://himera.herokuapp.com/synonym.html this should be part of the standard docs for clojurescript - or am i just blind and cannot find it? it would have saved me so much time *sob* On Mon, Apr 23, 2012 at 3:45 PM, David Nolen dnolen.li...@gmail.com wrote: http://himera.herokuapp.com/synonym.html -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ANN expectations-mode 0.0.2
Hey, I use the expectations testing framework a fair amount at work, so created an emacs minor mode for running the tests ala clojure-test-mode. It is based on clojure-test-mode so has many of the same keybindings: https://github.com/gar3thjon3s/expectations-mode/tree/0.0.2 I had to update expectations itself to add extra metadata onto its test vars, so it only works with = v1.3.7 or expectations. I have pushed expectations-mode to the marmalade-repo or you can just put it on your load-path and require it. Hope somebody else finds it useful, Cheers, Gaz -- 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 question about rebinding local variables
to answer your question directly, you would need to do something like this to make it work the way your example is set up: (defn new-game [] (let [board (atom (into [] (repeat 9 nil)))] (fn [n [i]] (cond (= n :x) (swap! board assoc i 'x) (= n :o) (swap! board assoc i 'o) (= n :print) (println @board) (def g1 (new-game)) (g1 :x 0) (g1 :print) On Thu, Apr 19, 2012 at 9:58 PM, Armando Blancas abm221...@gmail.com wrote: You could keep the board in an atom so it can mutate; then try to find maybe two good places for mutation to happen, your move and the program's. With the rest being functional you'll avoid the problems of global state while not being forced to fit your logic into a loop of some re-binding that simulates mutation. On Thursday, April 19, 2012 3:21:56 PM UTC-7, Craig Ching wrote: Ok, I've read that what I want to do is a no no. But this is the sort of thing I did in Scheme about 20 years ago (and because of that I'm probably misremembering ;-)). Basically I'm learning clojure and thought I'd write a tic tac toe game. But not any tic tac toe, I want to write one where I can have multiple games going simultaneously. Something like: (def g1 (new-game)) (def g2 (new-game)) (g1 :x 0) (g1 :print) (g2 :x 5) (g2 :print) So the schemer in me (and probably the imperative programmer as well) thought I could return a clojure that encapsulates the board value, something like this: (defn new-game [] (let [board (into [] (repeat 9 nil))] (fn [n i] (cond (= n :x)(set! board (assoc board i 'x)) (= n :o)(set! board (assoc board i 'o)) (= n :print) (println board) Of course I get an error saying I can't bind to the non-mutable board. I'm really new to Clojure, so apologies if this is really basic for this list. Can I do what I want or can someone point me in the right direction? I've seen some other tic tac toe implementations on github, but they use recur to track state and I was hoping there was a cleaner idiomatic way than that. Thanks! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ANN: Mississippi 1.0.0 - validating maps
Hey, Both myself and my brother do a fair amount of validating maps of data in our day jobs (EXCITE!) so we put together a library a while ago to help out. We just got round to releasing 1.0.0 recently so thought I would announce it here in case anyone else is interested: https://github.com/mikejones/mississippi Basic usage is like: user (use 'mississippi.core) user (def subject {:a nil :b 1}) user (def validations {:a [(comp not nil?) :msg required] :b [number? :msg not numeric]}) user (validate subject validations) {:a nil, :b 1, :errors {:a (required)}} It's fairly simple and there are more examples of other features and built-in validators in the README on the homepage, along with installation instructions etc. Hope others may find it useful. Cheers, -- 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: Polymorphic namespaces?
I would ask why you would want to do dependency injection? If it is to swap out functions for testing, just use 'with-redefs'. I have personally found it (DI) completely unnecessary... On Wed, Mar 28, 2012 at 1:13 PM, Chris McBride cmm7...@gmail.com wrote: I was wondering how dependency injection is done in Clojure since functions live in static namespaces. It seems like this could be achieved by having a macro that can use runtime information to determine the mapping between a namespace and its implementation. Does this make sense? Is there a better way to dependency injection in Clojure? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: Creating map from string
argh i come back to paste in my answer and you beat me to it :( i was gonna say: (let [s @key1 this is a value @another-key and another value @test1 and other value] (reduce (fn [m [_ k v]] (assoc m k (string/trim v))) {} (re-seq #(@[\w-]+)([^@]*) s))) much the same... On Sun, Mar 18, 2012 at 3:14 PM, David Powell djpow...@djpowell.net wrote: You could use a regexp to pick out the key and the value - something like this: (into {} (map (fn [[_ x y]] [(keyword x) (clojure.string/trim y)]) (re-seq #(@[^ ]*) *([^@]*) s))) -- Dave -- 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: Bret Victor - Inventing on Principle
Are you Ken Wesson with a new account? On Fri, Feb 24, 2012 at 1:00 PM, Cedric Greevey cgree...@gmail.com wrote: On Fri, Feb 24, 2012 at 1:29 PM, Damien Lepage damienlep...@gmail.com wrote: Hi Everyone, You may have seen this already, if not I believe it's worth investing 1h of your life: http://vimeo.com/36579366 That's already a good candidate for the technical talk of the year, if not the decade IMO. What is it with people these days and using videos for stuff that could be far better posted as text? A talk can inherently be presented as text, perhaps HTML with a few inline images if there are slides. And text (or HTML) has some HUGE advantages: * Download size is kilobytes, not gigabytes * Can be viewed on dialup, mobile, etc. without stuttering, not working at all, costing an arm and a leg, or etc. * Google can find it by the full content of the talk, not just what few keywords someone slaps onto the video's youtube page plus the inanities added by the inevitable swarm of troll commenters. * You can search in it yourself with ctrl-F in your browser. * You can skim it. * If you're a fast reader, you can probably read it and comprehend it all in less than an hour. * You can navigate in it very easily, using normal scrolling, search, and other browser tools, and see where you're going while you scroll, rather than having to drag a tiny little thingy across a tiny little seek bar blind, drop it, and then wait 40 seconds while a little wheel spins for the Flash player to *maybe* jump to the spot in the video, whereupon you will repeat the process a few times with ever finer adjustments; but the player might hang or snap back to where it was or crash instead. * You can keep a copy for offline viewing without needing: a) hacking tools to bypass the attempts by the popular video sites to be streaming-only, b) one or another big bloated piece of media player software that will steal file associations at inconvenient and random times, and c) a shitload of disk space. * No extra plugins etc. needed to view it that guzzle CPU and memory, crash at inconvenient times, and the like. You can view it in Lynx (minus the slides, if any) if you want to. You can view it on a 286 with no graphics card (not no 3D card, no graphics, period, just 80x24 text mode). You can view it on your old Commodore 64 with 300 baud modem if you want to and it won't take sixty thousand years to download on that either. * You can copy and paste bits of it into a snippets file or whatever, if there's bits you want to refer back to later that gave you technical ideas. Or print it out and apply hiliter to key passages. Or etc. * If you're blind you can still get screen-reader software to read it for you. If you're deaf, on the other hand, a video is quite likely to be completely useless, since streaming framerates and lip-reading don't tend to mix and none of these things seem to be closed-captioned. * Text is easy and cheap to mirror widely around the net and relatively easy to translate to other languages. Video can be hosted free at only a handful of sites and is more work to translate. What does video get you that text or HTML+images couldn't get you? * You can hear what the guy's voice actually sounds like. * You get to see a talking head bobbing around and lips moving in a jerky, stuttery sort of way. * You get the pronunciation, but not the spelling, of the obscure technical/latin words that get used, instead of the other way 'round. * There can be full-motion video demonstrations of things. Not worth what you lose, IMO, even if you aren't deaf, and especially if you are. Full-motion video demonstrations can be separate short videos embedded in a text+images web page. Oh, and by the way, your post doesn't even bother to actually say what, exactly, the talk is about. It implies strongly that it has something to do with interactive development tools, and it's clear that something in it wowed you, but that's it, and the URL itself is completely opaque. Apparently the only way to find out in more detail what the talk's topic is is to click the link, at minimum, and maybe you even have to play the video part-way. -- 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,
Re: Bret Victor - Inventing on Principle
nah it's possible i guess, but he's the only other person i've ever seen type an essay about it on this forum in reply to someone posting a link to a video. also, he posts and yours are very similar and he disappeared shortly before you arrived. AND YOU WOULD HAVE GOT AWAY WITH IT IF IT WASNT FOR THOSE MEDDLING KIDS!! On Fri, Feb 24, 2012 at 1:12 PM, Cedric Greevey cgree...@gmail.com wrote: On Fri, Feb 24, 2012 at 2:06 PM, gaz jones gareth.e.jo...@gmail.com wrote: Are you Ken Wesson with a new account? Who? Wait. Surely you don't think that it's not possible for more than one person to prefer text to video as a way of disseminating verbal information over the internet, given all of text's advantages in such areas as bandwidth, cost, and tool support? -- 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: Emacs: Optimize Imports?
I believe this might be what close to what you are looking for: https://github.com/technomancy/slamhound On Sun, Jan 1, 2012 at 1:03 PM, Daniel Glauser danglau...@gmail.com wrote: Hello folks, Does anyone know a way with Emacs/Leiningen/Slime/Swank to ask the system to optimize the imports? I'm looking for something similar to the way Intellij does things: http://www.jetbrains.com/idea/webhelp/optimizing-imports.html Converting existing Java example to Clojure and many of the examples don't include import statements. Working with recursive greps and opening the JARs in Emacs helps but I just wanted to ask around if anyone has an easier way. Tried bringing the project into Intellij with the Leiningen and La Clojure plugins but Code-Optimize Imports is disabled. Looks like this was asked about previously but no answer was reached. http://groups.google.com/group/clojure/browse_thread/thread/98f985926f096850/602f8ff61ec735ae?lnk=gstq=emacs+imports#602f8ff61ec735ae Cheers, Daniel -- 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: How to print to stdout from the repl without a nil at the end?
are you sure you're not just seeing the result of the function call in the repl? for example this: (ns filter.core (:require [clojure.string :as string]) (:gen-class)) (defn -main [ args] (loop [] (when-let [line (read-line)] (println (string/upper-case line)) (recur when run, produces: $ echo -e 'foo\nbar\nbaz' | java -cp lib/*:filter-1.0.0-SNAPSHOT.jar filter.core FOO BAR BAZ $ On Fri, Dec 30, 2011 at 1:38 PM, Frank Siebenlist frank.siebenl...@gmail.com wrote: I'm trying to write some filters in clojure from stdin to stdout, but I have this nil at the end of the stream, which is what print returns. As an alternative, I can return strings, but then I have the surrounding s. Or I could end by printing (symbol ), like (do (print hi)(symbol )) which kind of gives me what I'm looking for but seems to include a newline at the end. Any other suggestions maybe? Thanks, Frank. -- 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: How to print to stdout from the repl without a nil at the end?
Yes - I do get the result of the print function in the repl (i.e. nil), and I'm trying to see how I can somehow prevent that nil from printing to stdout. Yeah, the point I was making is that you are always going to see that 'nil' printed at the repl because it always evaluates and prints the result of the function, where as in reality that 'nil' would never get written to stdout (unless you explicitly captured it and wrote it yourself). It's the repl that's special - not the -main function. -- 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: Implementing a clojure-only periodic timer...
Hey Bill, I would have thought you would have to have a pretty good reason for not using an executor for this? (let [executor (Executors/newSingleThreadScheduledExecutor)] (.scheduleAtFixedRate executor your-func 0 3 TimeUnit/SECONDS)) On Thu, Dec 1, 2011 at 11:17 AM, Bill Caputo logos...@gmail.com wrote: Hi All, I am currently considering an approach similar to the following for periodically sending an update to an agent and I'm looking for feedback on whether there is anything wrong with it, whether it's idiomatic clojure (sorry I'm in the pro-that-term camp) and whether there are other pure-clojure alternatives I should consider (I also realize there are java-based periodic timers I could use as well): (def *timer* (agent nil)) ; perhaps an atom instead? (defn start-timer [ms a f] (letfn [(tfn [m] (future (do (Thread/sleep ms) (send a f) (send *timer* tfn] (send *timer* tfn))) given an agent: (def data (agent 0)) we could kick off an update every 3 seconds thusly: (start-timer 3000 data #(inc %)) A real implementation would likely have to address further considerations like stopping/cancelling the timer, not using a global for the timer, and what happens if start-timer is called twice, but this is the basic idea I'm considering... feedback welcome, thanks, 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 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: The Clojure way to solve this problem?
what about just re-defing the function inside the tests to the instrumented version? something like: (ns one.http) (defn get [] ...) (ns one.http-instrumented) (defn get [] ...) (ns one.test.blah) (with-redefs [one.http/get one.http-instrumented/get] ...) guess you could put the redefs into a function and use it as a fixture if you're using clojure.test? that would get rid of the flag and fork in the code O_o On Wed, Nov 30, 2011 at 5:53 PM, AndyK andy.kri...@gmail.com wrote: I have Clojure code which makes HTTP requests to a server. Depending on the context, I want to swap out the underlying HTTP library code. For example, I use an instrumented library in a testing context and a different library in a REPL context where the instrumented library will not work. These are low-lying functions - the http/get and http/ put - called within other functions for doing specific kinds of requests which are called in turn by other functions. What I'm wondering is what are good ways to dynamically choose which versions of those low-lying functions to use? For now, I'm doing this within the namespace that uses the low-lying functions.. (def get (if (context-flag?) ns.one.http-instrumented/get ns.two.http- repl/get)) What I don't like about this is that context-flag feeling like a hacky approach. Thoughts? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: A few questions on how to do things in more idiomatic ways
off top of my head i would probably do something like: 1. (- some-var (assoc :foo bar) other-operation and-another) (see threading macros) 2. (update-in some-map [:entry] #(or % (get-new-value))) in particular, im not sure if there is a more idiomatic way On Mon, Nov 21, 2011 at 12:46 AM, gchristnsn gchrist...@gmail.com wrote: 1. Often I use the following construct: (let [some-var (initial-binding) some-var (some operations (assoc, etc.) using some-var pvevious binding) some-var (some operations using some-var pvevious binding several times)] (more operations on some-var)) This is probably something like the `do' monad, and I like the thing that the usage of previous binding of the variable is possible freely anywhere in the context without wrapping operations with fn and calling threading operator. But things become bad if misspelling occurs. Are there some library macros for such operations, or possibility to do this in less error- prone way? 2. Let's assume that there is a map with key :entry, and I need to assoc new value for this key if it's nil or leave map as is otherwise. I do this in following way: ... (let [some-map (if (:entry some-map) some-map (assoc some-map :entry (get-new-value)))] ... The question is the same: what is the most correct way to do 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 -- 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: get all record instances
could you not just use a map? (def sources {:bbc bbc.co.uk :google google.com ...}) On Sat, Nov 5, 2011 at 6:14 AM, Mark Derricutt m...@talios.com wrote: Would something like: (def ^:dynamic *SOURCES* (ref [])) (defrecord Source [name url]) (defmacro defsource [name url] `(dosync (alter *SOURCES* conj (Source. ~name ~url (defn get-all-sources [] @*SOURCES*) (defsource Google google.com) do ok? Man - it's been too long since I've done clojure - so rusty :) -- Great artists are extremely selfish and arrogant things — Steven Wilson, Porcupine Tree On Sat, Nov 5, 2011 at 11:03 PM, Colin Taylor colin.tay...@gmail.com wrote: Hi, given a namespace sources with [simplified definitions] (defrecord Source [name url]) (def google (source Google google.com)) (def bbc (source BBC bbc.co.uk)) (def nbc ... etc. what would be the idiomatic way to implement (defn get-all-sources) cheers Colin -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ANN tools.cli 0.2.1
Changes in 0.2.1 (should make it to maven central soon): * :required option no longer supported, caused issues when trying to provide your own --help and you have other parameters that are required. You must now validate your own required parameters, eg: (let [[options args banner] (cli [] [-f --foo])] (when-not (:foo options) (println Foo is required) (println banner) (System/exit 0)) ...) Thanks, Gaz -- 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
update to clojure.tools.cli
Hi, I have made some changes to tools.cli to fix an annoying bug arround boolean flags and the inability to collect 'trailing arguments'. Whilst gathering opinions on these changes, a few other suggestions were made such as removing all magic functions and System/exit calls. The update is therefore going to break the existing API which you obviously need to be aware of if you are currently using 0.1.0 and intend to upgrade to 0.2.0. The release has been cut, but the last time I checked it still hadn't hit maven central, so this is slightly advanced notice. To see details of the new api please see: https://github.com/clojure/tools.cli. There are a few things worth mentioning... support for grouped options has been removed, and the result of the call to cli is now a vector of [options, trailing arguments, usage banner] (originally it was just a hash of options). Automatic help is also no longer provided, an example of how to roll your own is at the bottom of the aforementioned page. a brief example of the differences (see the site for full details though): 0.1.0: (cli [-p 8080 -v --foo bar some-filename] (optional [-p --port The port] #(Integer. %)) (optional [-f --foo Some foos]) (optional [-v --[no-]verbose Be chatty]) = {:port 8080, :foo bar, :verbose true} 0.2.0: (cli [-p 8080 --foo bar -v some-filename] [-p --port The port :parse-fn #(Integer. %)] [-f --foo Some foos] [-v --[no-]verbose Be chatty :default false]) = [{:port 8080, :foo bar, :verbose true}, [some-filename], *the usage banner*] Apologies for anyone upset by the timing / notification of the changes -- I will give greater advanced notice in future if there are any more breaking changes (hopefully there wont be :D) -- 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: Please announce release breaking API changes of libraries hosted at github.com/clojure on this mailing list
Hey dude, as I mentioned in the git link you pointed at there... apologies for any confusion. The intent was always to make an announcement WRT the breaking changes. I think you just caught me in the middle of the merging the changes into master and getting a release cut process. I am not making breaking changes with the intention of antagonizing people :D ... OR AM I On Tue, Nov 1, 2011 at 11:49 AM, Michael Klishin michael.s.klis...@gmail.com wrote: not -- 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: Please announce release breaking API changes of libraries hosted at github.com/clojure on this mailing list
Just to clarify.. no I'm not. On Tue, Nov 1, 2011 at 2:52 PM, gaz jones gareth.e.jo...@gmail.com wrote: Hey dude, as I mentioned in the git link you pointed at there... apologies for any confusion. The intent was always to make an announcement WRT the breaking changes. I think you just caught me in the middle of the merging the changes into master and getting a release cut process. I am not making breaking changes with the intention of antagonizing people :D ... OR AM I On Tue, Nov 1, 2011 at 11:49 AM, Michael Klishin michael.s.klis...@gmail.com wrote: not -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: {ANN} clojure-control 0.2.1 released.
thanks for sharing, this looks extremely useful. On Mon, Oct 31, 2011 at 11:43 AM, dennis killme2...@gmail.com wrote: Clojure-control is a clojure DSL for system admin and deployment with many remote machines via ssh/rsync.It is on github: https://github.com/killme2008/clojure-control 0.2.1 has been released,main highlights: First,A shell command DSL by sunny87,for example: (cd /home/login (run ls) (cd bin (run ls))) (cd /home/login (path /home/login/bin (env JAVA_OPTS -XMaxPermSize=128m (run clojure Second,Supports ssh/scp/rsync options when defining cluster,they can be a string or a vector: (defcluster :mycluster :ssh-options -p 44 :scp-options -v :rsync-options [-arz --delete] :clients [ { :host c.domain.com :user clogin :ssh- options -v -p 43} ] :user login :addresses [a.domain.com b.domain.com]) Third, It supports executing task in parallel now,just define cluster by (defcluster :mycluster :parallel true ) At last, i recommend everyone try the lein-control plugin developed by sunny87 for using cc much more simply,please visit https://github.com/sunng87/lein-control -- 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: trouble setting up emacs
some kind soul gave me this on the mailing list a while ago, works for me: ;; fix the PATH variable (defun set-exec-path-from-shell-PATH () (let ((path-from-shell (shell-command-to-string $SHELL -i -c 'echo $PATH'))) (setenv PATH path-from-shell) (setq exec-path (split-string path-from-shell path-separator (if window-system (set-exec-path-from-shell-PATH)) shove that in your init.el or wherever you are putting your customisations. it adds your shell path to emacs path and should enable emacs to find lein. On Mon, Oct 24, 2011 at 6:28 PM, Howard Lewis Ship hls...@gmail.com wrote: I've gotten as far as changing to a directory with a project.clj and execute C-c C-j C-i I see this in my *swank* buffer: Process swank exited abnormally with code 127 sh: line 1: lein: command not found lein is on my search path (in ~/bin). Where do I update things so that it is on the path for the Swank process? On Tue, Oct 18, 2011 at 4:07 AM, MarisO maris.orbid...@gmail.com wrote: run this script in your .emacs.d directory -- #!/bin/sh git clone https://github.com/technomancy/clojure-mode.git wget -P paredit http://mumble.net/~campbell/emacs/paredit.el wget http://download.savannah.gnu.org/releases/color-theme/color-theme-6.6.0.tar.gz mkdir color-theme tar --strip-components=1 --directory=color-theme -xzf color- theme-6.6.0.tar.gz rm color-theme-6.6.0.tar.gz -- init.el -- (add-to-list 'load-path ~/.emacs.d/) ;; clojure-mode (add-to-list 'load-path ~/.emacs.d/clojure-mode) (require 'clojure-mode) (fset 'compile-and-goto-repl \C-x\C-s\C-c\C-k\C-c\C-z) (global-set-key (kbd C-c C-g C-r) 'compile-and-goto-repl) (global-set-key (kbd C-c C-j C-i) 'clojure-jack-in) ;; paredit (add-to-list 'load-path ~/.emacs.d/paredit) (require 'paredit) (add-hook 'clojure-mode-hook 'enable-paredit-mode) (global-set-key (kbd M-p M-m e) 'enable-paredit-mode) (global-set-key (kbd M-p M-m d) 'disable-paredit-mode) ;; color theme (add-to-list 'load-path ~/.emacs.d/color-theme) (require 'color-theme) (eval-after-load color-theme '(progn (color-theme-initialize))) -- Start emacs, change current directory (M-x cd) to a leiningen project root and press C-c C-j C-i. It should start clojure repl. You will need swank as dev dependency. :dev-dependencies [[swank-clojure 1.3.1] [midje 1.1.1]] hth, Maris On Oct 18, 4:32 am, Bruce Gordon brucebgor...@gmail.com wrote: I am trying to follow the directions athttp://dev.clojure.org/display/doc/Getting+Started+with+Emacs. 1. I want to install the Emacs Starter Kit. The directions athttp://dev.clojure.org/display/doc/Getting+Started+with+Emacsmention GNU Emacs 23 or 24 is recommended, however https://github.com/technomancy/emacs-starter-kit says You'll need Emacs 24. The directions say precompiled versions are readily available for Debian-based systems I'm using a Debian based system. so I went tohttp://emacs.naquadah.org/. a. I executed wget -q -O -http://emacs.naquadah.org/key.gpg| sudo apt-key add - b. I'm now confused as to which version I want: Stable? If so I should then follow the directions to add 2 lines to /etc/apt/sources.list, and then what do I do? 2. Once I get emacs 24 installed, the directions sort of leave off with In both cases, you need to launch a Clojure instance with the correct classpath settings. This is most commonly done using a build tool such as Leiningen. For instructions see the Build Tools section of Getting Started. Going tohttp://dev.clojure.org/display/doc/Getting+Started and perusing the Build Tools doesn't explain how to setup and launch a Clojure instance. I see some explanations athttp://blog.bensmann.com/setting-up-a-clojure-development-environment but don't know if that includes some obsolete directions. thanks, -Bruce -- 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 -- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post.
Re: Rounding the edges of an Emacs beginner
M-{ and M-} in emacs go forward/backwards a paragraph. when in code, this often translates well to moving around between fragments/functions etc. you also have C-v and M-v for forward/backward a page and then C-l for centering on the current line. i use all of those a lot... On Thu, Sep 15, 2011 at 2:15 AM, Stefan Kamphausen ska2...@googlemail.com wrote: Hi, we're getting totally OT here and should probably better head for gnu.emacs.help. Anyway, just one more bark from me and then I'll be quiet (but will respond to mail ;-) On Thursday, September 15, 2011 2:08:28 AM UTC+2, frye wrote: In Vim , you press Ctrl-d and Ctrl-u to go down and up a block respectively. Depending on the size of your window, it moves the cursor about 1/3rd of the way down (or up) the screen. This is very handy to have when just browsing a buffer. You can be more precise by pressing 37k, to move the cursor up 37 lines, etc. For whatever reason, I haven't been able to find something similar in Emacs. OK, I tried what it does in vim. Some things come to my mind. 1. PgUp/PgDn obviously 2. Try hitting C-l (that's an 'l' like in 'like') several times in a row. It won't move your cursor but the line it's on. 3. I've been using some personal binding on my home and end keys for ages which moves me to the beginning/end of a line, beginning/end of the currently displayed window and beginning/end of the whole buffer on successive hits. See chb-home and chb-end on http://www.skamphausen.de/cgi-bin/ska/dot-emacs.d-slash-init.el. Combine that with C-l. 4. You might want to try out swiss-move.el (shameless self-plug). Maybe it's confusing, maybe helpful. Cheers, Stefan -- 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: Please optimize this with macro (grep and context result grabing)
do you know about the re-groups function, or are you just doing this for an exercise? On Fri, Aug 26, 2011 at 6:57 PM, Michael Jaaka michael.ja...@googlemail.com wrote: Hi! I have got (def *g) (def *g1) (def *g2) (def *g3) (def *g4) (def *g5) (def *g6) (defmacro grep[ pat in body ] `(do (when-let[ r# (re-matches (re-pattern ~pat) ~in) ] (binding [ *g (first r#) *g1 (get r# 1) *g2 (get r# 2) *g3 (get r# 3) *g4 (get r# 4) *g5 (get r# 5) *g6 (get r# 6) ] ~@body (grep (.+)-(.+) 1-4 (println *g *g1 *g2) ) I need to optimize the *gx so it won't look like hand written. Anyone? I was trying to use with-bindings and #' but it doesn't work. Also push and pop of thread bindings didn't want to work. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure.java.jdbc: mapping BigDecimal to double
the oracle jdbc adapter returns a whole host of strange datatypes. for instance, it returns bigdecimals for numbers you have mapped to be numbers (with a precision, without a scale) in the table. it also returns its own custom time classes. these generally have a toJdbc() method to convert them to the 'expected' jdbc type. a quick look under the covers of any other language's db libraries (such as activerecord or sequel) shows a whole host of these annoying conversions back and forth. to be honest, the lack of the conversion in java.jdbc is great as i can decide what i want to convert / not convert. tldr oracle jdbc is shit :P On Tue, Aug 23, 2011 at 8:54 PM, HiHeelHottie hiheelhot...@gmail.com wrote: Hey Sean, I really appreciate the quick response and your work with java.jdbc. Completely agree with you that it shouldn't automatically map out of the box. As a newbie to clojure and jdbc, do you have any advice on how I can get into resultset-seq* to do the mapping? I think it would be better not to have to map a BigDecimal to double after resultset- seq* returns a row. Are there any future plans to add a mapping api to resultset-seq or is the pattern just to chain any custom mappings after resultset-seq? On Aug 23, 9:41 pm, Sean Corfield seancorfi...@gmail.com wrote: No, you'd have to do it yourself. Since not all BigDecimal values would fit correctly in double, it would be dangerous for resultset-seq to do it. I expect there are all sorts of JDBC data types that don't quite match Clojure types but I don't think automatically mapping them would be a good idea... Sean On Tue, Aug 23, 2011 at 6:16 PM, HiHeelHottie hiheelhot...@gmail.com wrote: It looks like Oracle NUMBER types get mapped to BigDecimal in a result seq from clojure.java.jdbc. Is there an easy way to configure clojure.java.jdbc/ResultSet to map Oracle NUMBERS to doubles? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure.contrib.command-line
it lives on github: http://github.com/clojure/tools.cli like all the new contrib libs, to use it in a project you need to add it to your dependencies: :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/tools.cli 0.1.0]] On Fri, Jul 29, 2011 at 7:56 AM, octopusgrabbus octopusgrab...@gmail.com wrote: On Jul 28, 7:24 pm, Anthony Grimes disciplera...@gmail.com wrote: command-line is deprecated in favor of tools.cli now.http://github.com/clojure/tools.cli Where is the repository located? (ns addr-verify (:gen-class) (:require [clojure.tools.cli :only (cli optional)]) . . . results in this error: clojure.lang.Compiler$CompilerException: java.io.FileNotFoundException: Could not locate clojure/tools/ cli__init.class or clojure/tools/cli.clj on classpath: -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure.contrib.command-line
Well, README and tests are very good. I withdrew into REPL and overlooked them stupidly. I'm very sorry. no worries, glad they help. BTW some functions seems not to be public API though they are public. Why they are not separated by defn- or specific namespace like clojure.tools.cli.internals? no reason other than its a small lib with a handful of functions... -- 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: Libraries and build management hell
i would agree with all that if i were writing plain java (a lib dir for dependencies and a couple of shell scripts for building etc), but leiningen makes it so easy for clojure that its more work _not_ to use it... at least that has been my experience. On Thu, Jul 28, 2011 at 4:23 PM, Michal B mibu.cloj...@gmail.com wrote: Why does it have to be so complicated to use libraries? To use libraries, you need to learn how to operate half a dozen build tools and git because each library author distributes their library differently. If figuring out how to install an IDE with clojure wasn't bad enough, now you need to figure out how to install and use each of the tools with it. I'm not saying build tools are useless, on the contrary. It's just that most of the time, we want to sling two or three libraries together and code. Right? There is no need to start a project with a bunch of template files and an elaborate directory structure and to start configuring dependencies and to rely on some magic happening that makes your program run. I think we over-engineered the build process to support the big projects and forgot the common case. Most projects are simple. Let's remove this incidental complexity by returning to simplicity. Keep the build tools for the heavyweights and get back in touch with your libraries. Instead of having a complicated installation guide for your library, have a Download section in your site. Have there a link to the latest stable version of your library as a jar file or, if necessary, a zip file with your jar and and all the necessary dependency jars (sane library authors won't mind). For a zip, shortly describe what's in it - library names and versions, and links to their sites. That's it. I think most JVM users know or can quickly figure out how to take jars and put them in their project's classpath. It's simple to do with all IDEs (or without one) and there is no need to learn or install additional software or edit configuration files. Starter scripts should include in the classpath all jars in the current directory or jars/ directory by default. Instead of managing libraries inside a dependencies file, you do it directly with the jar files. If the project gets too big, bring in the build tools. What are your thoughts on this issue? -- 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: Digest for clojure@googlegroups.com - 14 Messages in 9 Topics
libraries? I used to think it was hard until I read up on lein. Can't get much simpler than clojars and lein: http://clojars.org/ http://alexott.net/en/clojure/ClojureLein.html Now I'm starting to think that I actually like the lein method over python easy_install or ruby gems. Timothy -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) gaz jones gareth.e.jo...@gmail.com Jul 28 04:31PM -0500 ^ i would agree with all that if i were writing plain java (a lib dir for dependencies and a couple of shell scripts for building etc), but leiningen makes it so easy for clojure that its more work _not_ to use it... at least that has been my experience. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure.contrib.command-line
are there any scenarios in particular you feel need more documentation? im happy to add more if it is lacking. hopefully the README on the project page and tests provide a pretty good idea of what options are available: https://github.com/clojure/tools.cli https://github.com/clojure/tools.cli/blob/master/src/test/clojure/clojure/tools/cli_test.clj 2011/7/28 OGINO Masanori masanori.og...@gmail.com: (defn -main [ args] (with-command-line args Get csv file name [[in-file-name .csv input file name resultset.csv ]] (println in-file-name:, in-file-name))) The second vector of vector seems unnecessary. Or tools.cli way: (ns foo.main (:gen-class) (:use [clojure.tools.cli :only (cli optional)])) (defn parse-opts [args] (cli args (optional [--in-file-name .csv input file :default resultset.csv] identity))) (defn -main [ args] (let [opts (parse-opts args)] (println in-file-name: (:in-file-name opts It might be verbose but I think it is more descriptive than with-command-line one. However, I'd like more documents and examples about tools.cli. -- Name: OGINO Masanori (荻野 雅紀) E-mail: masanori.og...@gmail.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: The Last Programming Language
this made me lol :D a big will smith fan??? not that i know you at all other than reading your posts here, but i really didnt see that coming... On Tue, Jul 19, 2011 at 9:11 AM, Ken Wesson kwess...@gmail.com wrote: An hour of Will Smith blasting aliens flies by. An hour of a talking head is better presented as text. -- 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: Mocking framework
jay fields has a good blog post on this: http://blog.jayfields.com/2010/09/clojure-mocking.html On Tue, Jun 28, 2011 at 2:52 AM, Ola Ellnestam ola.ellnes...@agical.se wrote: Hi Erik, Take a closer look at Midje, especially https://github.com/marick/Midje/wiki/Metaconstants I'm not an subject matter expert but to me it's close enough to mocking/stubbing. Cheers, Ola Erik Bakstad skrev 2011-06-28 08:56: Hi, I'm currently working on my first real Clojure project, and I find myself wanting a mocking tool. So I was wondering what you are using? I tried googling, but I can't seem to find the Mockito of the clojure world. Searching for a mocking tool in Clojure it looks like there is a lot of small tools being thrown together, but maybe not being used by many? The one exception maybe is https://github.com/marick/Midje? Thanks, Erik. -- - Ola Ellnestam Agical AB Västerlånggatan 79, 2 tr 111 29 Stockholm, SWEDEN Mobile: +46-708-754000 E-mail: ola.ellnes...@agical.se Blog: http://ellnestam.wordpress.com Twitter: ellnestam -- 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: ClassCastException on 'clojure.data.json/print-json'
are you trying to turn something into a json string? if so, the json-str function is probably what you are looking for: user (json/json-str {:a b}) {\a\:\b\} by the way, the nil in your previous email is not being suffixed to the string, its simply the return of the function getting written to stdout by the repl immediately after the function has printed there also. simply pressing enter at the repl will cause 'nil' to be printed too... On Tue, Jun 28, 2011 at 8:46 PM, Timothy Washington twash...@gmail.com wrote: Ok, so I fixed the problem by changing A) to B) A) (defn print-json ... (write-json x *out* escape-unicode))) to B) (defn print-json ... (write-json (PrintWriter. *out*) escape-unicode))) The only thing now, is that the 'nil' return value suffixes itself. I can find out where that is. But I think this this could be fixed easily enough. If you like, I can do this locally and, I guessing, submit a github pull request. user = (clojure.data.json/print-json tim) timnil user= (clojure.data.json/print-json [1 2 3]) [1,2,3]nil user = (clojure.data.json/print-json { :a { :aa b } } ) {a:{aa:b}}nil Tim On Tue, Jun 28, 2011 at 8:59 PM, Timothy Washington twash...@gmail.com wrote: I'm trying to do a simple print-json, and am getting a ClassCastException in the data.json library. I'm using [org.clojure/clojure 1.3.0-beta1] and [org.clojure/data.json 0.1.0]. So… lein repl … user = (require 'clojure.data.json) nil user = (clojure.data.json/print-json tim) ClassCastException java.io.OutputStreamWriter cannot be cast to java.io.PrintWriter clojure.data.json/write-json-string (json.clj:229) user= (clojure.data.json/print-json [1 2 3]) ClassCastException java.io.OutputStreamWriter cannot be cast to java.io.PrintWriter clojure.data.json/write-json-array (json.clj:254) user = (clojure.data.json/print-json { :a { :aa b } } ) ClassCastException java.io.OutputStreamWriter cannot be cast to java.io.PrintWriter clojure.data.json/write-json-object (json.clj:238) Seems fairly straightforward (I've also tried on lists, nested hashes, etc). If I look at the source for json:229 , the 'out' variable looks to be a PrintWriter (and my local source version is the same). And a stacktrace gives exactly that location user= (. *e printStackTrace) java.lang.ClassCastException: java.io.OutputStreamWriter cannot be cast to java.io.PrintWriter at clojure.data.json$write_json_string.invoke(json.clj:229) at clojure.data.json$eval108$fn__109$G__99__118.invoke(json.clj:201) at clojure.data.json$print_json.doInvoke(json.clj:331) at clojure.lang.RestFn.invoke(RestFn.java:410) at user$eval212.invoke(NO_SOURCE_FILE:24) at clojure.lang.Compiler.eval(Compiler.java:6406) at clojure.lang.Compiler.eval(Compiler.java:6372) at clojure.core$eval.invoke(core.clj:2745) at clojure.main$repl$read_eval_print__6016.invoke(main.clj:244) at clojure.main$repl$fn__6021.invoke(main.clj:265) at clojure.main$repl.doInvoke(main.clj:265) at clojure.lang.RestFn.invoke(RestFn.java:512) at user$eval7$acc__1060__auto8$fn__10.invoke(NO_SOURCE_FILE:1) at clojure.lang.AFn.run(AFn.java:24) at java.lang.Thread.run(Thread.java:636) nil user= Is there a problem in the data.json lib? Tim -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: Radically simplified Emacs and SLIME setup
this is really great, thanks for putting this together. i have a (possibly daft) question -- is there a neat way to kill/restart the underlying process. i have looked for a *ahem* clojure-jack-off function or equivalent but couldnt find one in the source. i am just killing it from the terminal at the moment and re-running clojure-jack-in... is there a better way? slime-disconnect seems to leave the underlying process still running in list-processes. thanks again! gaz On Fri, Jun 17, 2011 at 3:35 PM, Jeff Dik s45...@gmail.com wrote: Mark, I got this same error when I copied and pasted the clojure-jack-in function from gmail. I had to remove newlines from (search-backward slime-load-hook) and (slime-connect localhost clojure-swank-port) Hope that helps, Jeff On Sun, Jun 12, 2011 at 8:50 PM, Mark Engelberg mark.engelb...@gmail.com wrote: error in process filter: Search failed: slime-load-hook On Sun, Jun 12, 2011 at 4:51 PM, Phil Hagelberg p...@hagelb.org wrote: On Jun 12, 10:58 am, Mark Engelberg mark.engelb...@gmail.com wrote: I take that back (I had edited the wrong file, which wasn't the one my emacs was using). I get the error Not enough arguments for format string. Oops; I forgot to mention it also needs this: (defvar clojure-swank-command lein jack-in %s ) to replace the old clojure-swank-command defvar. -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 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Radically simplified Emacs and SLIME setup
awesome, it works. many thanks :D i clearly need to read the slime manual On Thu, Jun 23, 2011 at 10:24 AM, Sam Ritchie sritchi...@gmail.com wrote: This should do the trick, though I'm not set up with jack-in to test: At the REPL, type comma (the character ,), then sayoonara. On Thu, Jun 23, 2011 at 11:20 AM, gaz jones gareth.e.jo...@gmail.com wrote: this is really great, thanks for putting this together. i have a (possibly daft) question -- is there a neat way to kill/restart the underlying process. i have looked for a *ahem* clojure-jack-off function or equivalent but couldnt find one in the source. i am just killing it from the terminal at the moment and re-running clojure-jack-in... is there a better way? slime-disconnect seems to leave the underlying process still running in list-processes. thanks again! gaz On Fri, Jun 17, 2011 at 3:35 PM, Jeff Dik s45...@gmail.com wrote: Mark, I got this same error when I copied and pasted the clojure-jack-in function from gmail. I had to remove newlines from (search-backward slime-load-hook) and (slime-connect localhost clojure-swank-port) Hope that helps, Jeff On Sun, Jun 12, 2011 at 8:50 PM, Mark Engelberg mark.engelb...@gmail.com wrote: error in process filter: Search failed: slime-load-hook On Sun, Jun 12, 2011 at 4:51 PM, Phil Hagelberg p...@hagelb.org wrote: On Jun 12, 10:58 am, Mark Engelberg mark.engelb...@gmail.com wrote: I take that back (I had edited the wrong file, which wasn't the one my emacs was using). I get the error Not enough arguments for format string. Oops; I forgot to mention it also needs this: (defvar clojure-swank-command lein jack-in %s ) to replace the old clojure-swank-command defvar. -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 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: A stupid jvm question
this page explains a bunch of ways of calling jruby from java: https://github.com/jruby/jruby/wiki/RedBridge think i would have to have pretty good reason before doing this (like wanting to use jruby as a user scripting language in a clojure app maybe)... On Fri, Jun 17, 2011 at 11:08 AM, Phil Hagelberg p...@hagelb.org wrote: flebber flebber.c...@gmail.com writes: On Jun 17, 8:39 pm, Zlatko Josic zlatko.jo...@gmail.com wrote: No one question is stupid. Any jvm language can use jvm byte code. For example you can use Java libraries in Scala, Clojure,.. Of course sometimes it is not natural fit. For example if you use Scala in Java you have to know Scala compiler will generate set/get methods. So it is possible but not practical to call jruby from within a clojure script? It's easy to go the other way: https://github.com/technomancy/clojure-gem -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 -- 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: Wisdom sought for functional iterative processing
if i was writing the java i would probably do a tell dont ask refactoring so that the operations had an applyTo method: ListItem items = initialItems (); for (Op op : operations) { op.applyTo(items); } not sure what your op data structure is, but i would image you could translate that to the clojure code also -- is that reasonable? On Mon, Jun 13, 2011 at 9:37 PM, Matthew Phillips mattp...@gmail.com wrote: Hello all, I've been programming Clojure now for long enough that I'm starting to think I'm at the point of being fluent … almost. One area that keeps tripping me up is iteratively processing a data structure when the processing is highly conditional and may take several overlapping paths. An example might help: Example (simplified from my current real problem): Say I need to iterate through a seq of encoded list operations and apply them to a list. Some ops will require me to remove an element from the list, some will require me to add an item to list, and some will require both. The way I'd write it in Java would be something like: ListItem items = initialItems (); for (Op op : operations) { if (op.requiresDelete ()) items.remove (op.indexToDelete ()); if (op.requiresAdd ()) items.add (op.indexToAdd (), op.newItem ()); } You could imagine arbitrarily complex conditions for the transforms. The only way I can think of to write it in Clojure is: (reduce (fn [items op] (let [items1 (if (:delete op) (drop-index (:delete op) items) items)] (if (:insert op) (cons (:insert op) items1) items1))) items ops) i.e. I'm using a cascade of conditional let's. This isn't _too_ bad in this case, but you can image how unreadable this could get. I have a vague idea that in Haskell you might use the ST monad to approximate updating data structure in place. Clojure has a monad library, so would this make sense here? Thanks for any enlightenment anyone is able to give. Matthew. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: Compojure: How to process GET query string
query string params appear in the params of the request: (GET /math {params :params} [] (get params :a) ;; 1 (get params :b) ;; 2 ... etc they will be keywords as above if you are using the wrap-keyword-params handler, otherwise strings. the syntax you are using above is for pulling values out of the url: (GET /math/:command [command] (str p command /p)) /math/some-value = psome-value/p the docs have more info on these things: https://github.com/weavejester/compojure/wiki/Routes-In-Detail hope that helps... On Wed, May 18, 2011 at 5:24 AM, finbeu info_pe...@t-online.de wrote: Hi I don't know how to extract the query string from a route. I guess it is pretty simply but I don't get it. http://localhost:8080/math/add?a=1b=2c=3 I quess they can be retrieved somehow with :query-string keyword? But I have no clue how. (GET /math/:command [command more] Thanks for your help. FB -- 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: Reading clojure code of larger domain specific projects
compojure is often put forward as an example of good idiomatic clojure code: https://github.com/weavejester/compojure On Mon, May 9, 2011 at 10:55 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 09.05.2011 um 17:36 schrieb Jonathan Fischer Friberg: I'm interested! The clojure source code is a pretty good read, hehe Jonathan https://github.com/clojure/clojure/tree/master/src/clj/clojure Although the code in the preamble of core there is explicitly *not* recommended to be taken as example for “good” code. http://dev.clojure.org/display/design/Library+Coding+Standards Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Any best practices for clojure + java mixed language projects?
you can set the source path in leiningen to be whatever you like. the sample file is quite useful for finding these things out: https://github.com/technomancy/leiningen/blob/master/sample.project.clj they key is :source-path. there is also a :java-source-path. cant say i have ever used that, but it looks like what you want... On Sun, May 1, 2011 at 11:47 AM, Dave Snowdon dave.snow...@gmail.com wrote: Hi folks I'm a long time Java/C++ developer who's been experimenting with toy clojure programs for a few of months. I've at last decided to give clojure a try for a more significant project but, given this will incorporate components written in java I'm not sure about the way to structure and build the project. I've handled mixed language projects (eg java + C++) before using ant but am keen to avoid ant this time around. Ideally, I'd like to use leiningen to build the project but I'm not sure how tightly leiningen is wedded to its default project directory layout. Instead of the default structure of: - project.clj - README - src -- myproject -- core.clj - test -- myproject -- core_test.clj I'd like something more like this: - project.clj - README - src -- clojure -- myproject -- core.clj -- java -- org --- example --- myproject - test -- clojure -- myproject -- core_test.clj -- java -- org --- example --- myproject Is this extra directory level to separate language specific parts possible in leiningen? If possible, is it even desirable or are there better ways to structure mixed language projects? Any tips and pointers to best practices would be welcome! thanks Dave -- 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: Enhancement for contrib.command-line
i wrote a command line arg library after wanting a bit more than the one in contrib gave me: https://github.com/gar3thjon3s/clargon i think you could do what you want using it... On Fri, Apr 29, 2011 at 12:26 PM, Sean Corfield seancorfi...@gmail.com wrote: Just an FYI. As part of the 1.3.0 release, the contrib libraries are getting a facelift: http://dev.clojure.org/display/design/Contrib+Library+Names clojure.contrib.command-line will become clojure.tools.cli - I'm not sure who the new maintainer is but they would be the person best placed to address your suggestion since the old contrib libraries will not be updated. I haven't used the command-line library so I can't really comment but, on the surface, the ability to print help from multiple places sounds useful. Sean On Thu, Apr 28, 2011 at 12:38 PM, knuthie knuther...@googlemail.com wrote: I am relatively new to clojure and while using the contrib.command- line, I found there is a place for a small improvement, at least for my usecase :-) I use the with-command-line macro and then check eg. that the remaining parameters, that are not caught amount to the right number (eg. I want to have a commandline, where there are options and at most two additional arguments). In case the check fails, it would be beautiful to print the help message that gets printed, when -h or -- help is provided. Currently I cannot call the print-help function because I do not have access to the necessary parameters. If the with-command-line macro would be slightly changed to add a binding to a print-usage function: like (let [~(symbol print-usage) #(print-help ~desc cmdmap#) ] then it be possible to do something like this: (with-command-line [-s 1 2] Usage: testfile [Options] configuration file outputfile [[synonyms? s? Use Synonyms][normalizer? n? Use Normalizer] files] (if (= 2 (count files)) (println (files 0)) ;;else (print-usage))) Is that a good idea? -- 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: (just) emacs mode
i highly recommend taking a look at Phil Hagelberg's emacs-starter-kit : https://github.com/technomancy/emacs-starter-kit.git it helped me a LOT when getting started with emacs in general, and emacs and clojure together. i also put together a couple of blog posts on my experience of using it which might be useful for you: http://blog.gaz-jones.com/post/2486737162/setting-up-clojure-development-on-osx-using-emacs-and http://blog.gaz-jones.com/post/2501842155/interactive-clojure-development-in-emacs-with-leiningen gaz On Wed, Apr 27, 2011 at 5:13 AM, John V johnv02...@gmail.com wrote: Hi, I would like to have syntax highlighting for Clojure code in Emacs. I am using Emacs on Windows (23.2.1). I found this page: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs ... but it was clearly much more involved than I was looking for. Nevertheless, I downloaded package.el, loaded it, set the location for marmalade, and gave it a shot, but as expected, it didn't work. It said, Failed to download 'gnu' archive. I would like to use Emacs as a text editor, not as a combination IDE/ ftp browser. Is there a clojure mode written which is simple to download and use? I used ILISP for many years, and I've encountered SLIME when I was using SBCL, but never got it working properly on Windows. I know how cool and powerful an integrated environment like ILISP can be, but also how buggy it can be, and at the moment, I just don't think it's worth the effort to get it working. For now, I prefer to run Clojure in a Command Prompt, and use Emacs solely as a text editor. Thanks very much for any advice. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: Slamhound (for reconstructing ns forms)
this looks awesome, tried it out on a project i have but sadly got the exception below. i'll try and figure it out later when i have more time to see if its something specific to my project, but thought i would let you know in case it is something obvious (it failed from both slime and lein) Exception in thread main java.lang.Exception: prefix cannot be nil (NO_SOURCE_FILE:1) at clojure.lang.Compiler.eval(Compiler.java:5440) at clojure.lang.Compiler.eval(Compiler.java:5415) at clojure.lang.Compiler.eval(Compiler.java:5391) at clojure.core$eval.invoke(core.clj:2382) at slam.hound.regrow$check_for_failure.invoke(regrow.clj:31) at slam.hound.regrow$regrow.invoke(regrow.clj:72) at slam.hound.regrow$regrow.invoke(regrow.clj:70) at slam.hound$reconstruct.invoke(hound.clj:10) at user$eval368.invoke(NO_SOURCE_FILE:1) at clojure.lang.Compiler.eval(Compiler.java:5424) at clojure.lang.Compiler.eval(Compiler.java:5415) at clojure.lang.Compiler.eval(Compiler.java:5415) at clojure.lang.Compiler.eval(Compiler.java:5391) at clojure.core$eval.invoke(core.clj:2382) at clojure.main$eval_opt.invoke(main.clj:235) at clojure.main$initialize.invoke(main.clj:254) at clojure.main$null_opt.invoke(main.clj:279) at clojure.main$main.doInvoke(main.clj:354) at clojure.lang.RestFn.invoke(RestFn.java:422) at clojure.lang.Var.invoke(Var.java:369) at clojure.lang.AFn.applyToHelper(AFn.java:165) at clojure.lang.Var.applyTo(Var.java:482) at clojure.main.main(main.java:37) Caused by: java.lang.Exception: prefix cannot be nil at clojure.core$load_libs.doInvoke(core.clj:4802) at clojure.lang.RestFn.applyTo(RestFn.java:138) at clojure.core$apply.invoke(core.clj:544) at clojure.core$use.doInvoke(core.clj:4880) at clojure.lang.RestFn.invoke(RestFn.java:409) at clj_lbm.core$eval386$loading__4410__auto387.invoke(NO_SOURCE_FILE:1) at clj_lbm.core$eval386.invoke(NO_SOURCE_FILE:1) at clojure.lang.Compiler.eval(Compiler.java:5424) ... 22 more On Mon, Apr 25, 2011 at 8:05 PM, Phil Hagelberg p...@hagelb.org wrote: So I just threw together a little tool to help with ns forms. I find often they accumulate a bunch of cruft over time where you no longer need a given :use or :require form. And sometimes you don't feel like finding exactly where on the classpath a given class is. Or maybe you're too lazy to type it; whatever. Slamhound helps with that. (ns my.namespace some doc string) (defn -main [ args] (pprint args) (io/copy (ByteArrayInputStream. (.getBytes hello)) (first args))) Look at that; all bare, missing all kinds of necessary stuff. Disgraceful. Release the hound! $ lein slamhound src/my/namespace.clj (ns my.namespace I have a doc string. (:use [clojure.pprint :only [pprint]]) (:require [clojure.java.io :as io]) (:import (java.io ByteArrayInputStream))) Tada! (also featuring Emacs integration: M-x slamhound) Enjoy: https://github.com/technomancy/slamhound -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 -- 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: Executing Future
the easiest way (i find) to test if something occurring on another thread has completed is using a latch: (deftest mohanr (let [latch (CountDownLatch. 1) service (Executors/newFixedThreadPool 10)] (doseq [x (range 1) :let [f (.submit service (proxy [Callable] [] (call [] (.countDown latch]] (is (= true (.await latch 1 TimeUnit/SECONDS)) its possible in your code the future isnt yet done, because you check immediately after submitting the task to the thread pool. hope that helps... On Mon, Apr 25, 2011 at 6:27 AM, MohanR radhakrishnan.mo...@gmail.com wrote: ( deftest teststream (def service ( Executors/newFixedThreadPool 10 )) (dotimes [x 1] (try (def futures (.submit service ( proxy [Callable][] ( call [] ( println Test ) ) ))) ( println ( str Future is done ? ( true? ( .isDone futures ) ))) (catch ExecutionException e ( .cancel futures ) ) (catch Exception e ( .cancel futures ) ) ) )) This is again a beginner's question. Why is the future not done here ? I am getting 'false' and I believe there are simple mistakes in the code. There is no exception though. -- 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: Tranforming an ACL file: Comparing Clojure with Ruby
i was gonna suggest this: (let [users (- (split (slurp acl) #\n) (map #(split % #\|)) (map (fn [[a u p]] [a (split u #,) p])) (filter (fn [[a _ _]] (= avail a))) (mapcat (fn [[_ users path]] (map #(hash-map % [path]) users))) (apply merge-with into))] users) then i read the bit about readable... :P On Thu, Mar 3, 2011 at 8:51 PM, Stuart Halloway stuart.hallo...@gmail.com wrote: Dear Clojure Group, I am currently reading the online book Pro Git. In chapter 7.4 (section “Enforcing a User-Based ACL System”) there is a task of reading in an access control list (ACL) file, such as the following # avail/unavail | users | path avail|nickh,pjhyett,defunkt,tpw avail|usinclair,cdickens,ebronte|doc avail|schacon|lib avail|schacon|tests and printing out a map of the form { user1 [path 1, path 2], user2 [path2, path3] ...}. The author of the book provides a solution in Ruby, which I find relatively easy to follow, despite not having written any Ruby code before: def get_acl_access_data(acl_file) # read in ACL data acl_file = File.read(acl_file).split(\n).reject { |line| line == '' } access = {} acl_file.each do |line| avail, users, path = line.split('|') next unless avail == 'avail' users.split(',').each do |user| access[user] ||= [] access[user] path end end access end I then tried the same in Clojure, but found my solution to be much less readable compared to the Ruby code: (use '[clojure.string :only (split)]) (defn get-acl-access-data [file] (let [acl (split (slurp file) #\n)] (apply merge-with #(into %1 %2) (map (fn [[avail users path]] (let [users (split users #,)] (reduce (fn [acc user] (when (= avail avail) (assoc acc user [path]))) {} users))) (map #(split % #\|) acl) ;; Output: ;; {schacon [lib tests], ;; usinclair [doc], ;; cdickens [doc], ;; ebronte [doc], ;; tpw [nil], ;; defunkt [nil], ;; pjhyett [nil], ;; nickh [nil]} Maybe it is just because I am still a beginner, but I am afraid I won’t be able to figure out immediately what this code is doing a few weeks from now. However, I am sure there must be a better way of translating the Ruby version into Clojure. My main goal is on clarity, as I often struggle organizing my code in a way I would consider readable. I therefore would be glad for any ideas of improvement. Any suggestions are highly welcome! Best regards, Stefan Both the approaches above have the weakness that the steps are commingled, making it difficult to test (or reuse) part of the work done by the fn. Here is a Clojure version that makes the steps more distinct: (require '[clojure.string :as str]) (require '[clojure.java.io :as io]) (with-open [r (io/reader somefile)] (- (line-seq r) (map #(str/split % #\|)) (filter #(= avail (first %))) (mapcat (fn [[_ users path]] (map hash-map (str/split users #,) (repeat [path] (apply merge-with into))) From this it is easy to see that the fn: 1. splits the lines on | 2. filters on avail 3. builds a list of user|path pairs 4. merges the user|path pairs into a map Stuart Halloway Clojure/core http://clojure.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: Sorting of function definitions in namespaces
Well... It is Robert C. Martin's opinion. Who? 'uncle' bob martin: http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882 Also, it's pretty easy to just reverse the level of abstraction ordering from bottom-to-top is it not? I usually jump to the bottom of the file to start with when editing Clojure code... On Fri, Feb 11, 2011 at 10:05 AM, Fogus mefo...@gmail.com wrote: Well... It is Robert C. Martin's opinion. Who? I should have said that I _think_ that it is essential to writing readable code. I definitely agree with this. Another thing that I happen to agree with is that Clojure's model fits my way of programming in Clojure. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 won't leiningen install for me?
i would totally recommend uninstalling macports, and moving over to homebrew which is far better (https://github.com/mxcl/homebrew). On Mon, Jan 24, 2011 at 8:44 PM, Alex Osborne a...@meshy.org wrote: Hi Larry, As a quick temporary workaround you could just set your PATH environment variable so that it picks up the curl executable from /usr/bin instead of the broken MacPorts one from /opt/local/bin. $ which curl /opt/local/bin/curl $ export PATH=/usr/bin:$PATH $ which curl /usr/bin/curl You'll need to do that each time you install/upgrade Leiningen though. Since you're not using MacPorts, personally I'd opt to just rename the entire MacPorts directory (/opt/local) out of the way: $ sudo mv /opt/local /opt/local.broken You could then delete it or reinstall it at a later time, whatever you prefer. Cheers, Alex Mark Rathwell mark.rathw...@gmail.com writes: Seems pretty clear that your macports version of curl is the problem, it's up to you what you want to do about it. I don't know if uninstalling it would leave you with the OS X version of curl or not. Link to get you started: http://www.richarddooling.com/index.php/2009/09/12/macports-on-snow-leopard/ On Mon, Jan 24, 2011 at 7:29 PM, Larry Travis tra...@cs.wisc.edu wrote: Mark, John, Gaz: Your responses are all suggestive but I don't know where to go from here so I am going to make one more cry for help -- and to this group rather than the leiningen-specific one suggested by Mark because my basic problem is really how-to-get-clojure/emacs-running-under-MacOsX. Here is the situation, and my further questions: --- larrytravis$ lein-install.sh self-install Downloading Leiningen now... dyld: Library not loaded: /opt/local/lib/libintl.8.dylib Referenced from: /opt/local/bin/curl Reason: no suitable image found. Did find: /opt/local/lib/libintl.8.dylib: mach-o, but wrong architecture /Users/larrytravis/bin/lein-install.sh: line 175: 2851 Trace/BPT trap $HTTP_CLIENT $LEIN_JAR $LEIN_URL Failed to downloadhttps://github.com/downloads/technomancy/leiningen/leiningen-1.4.2-st... -- 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: Why won't leiningen install for me?
are you sure you dont have curl installed by macports or something? /usr/bin/curl on mac os x works fine with https for me... someone at work had this problem and they had (unknowingly) installed curl through macports... On Sat, Jan 22, 2011 at 1:28 PM, Bizics john.stuart.hun...@gmail.com wrote: Hi Larry, I had problems installing too. Turns out curl on mac os x does not support https as required by github now. I had to download and rebuild curl with the +ssl flag for https to be supported and then things worked fine. I could dig up my notes from when I did it if you need more information. Cheers, John On Jan 21, 4:49 pm, Larry Travis tra...@cs.wisc.edu wrote: I get the following when I try to install Leiningen: --- larrytravis$ lein-install.sh self-install Downloading Leiningen now... dyld: Library not loaded: /opt/local/lib/libintl.8.dylib Referenced from: /opt/local/bin/curl Reason: no suitable image found. Did find: /opt/local/lib/libintl.8.dylib: mach-o, but wrong architecture /Users/larrytravis/bin/lein-install.sh: line 175: 2851 Trace/BPT trap $HTTP_CLIENT $LEIN_JAR $LEIN_URL Failed to downloadhttps://github.com/downloads/technomancy/leiningen/leiningen-1.4.2-st... Can anybody advise me as to what I am doing wrong? /lein-install.sh/ is the script available at: https://github.com/technomancy/leiningen/raw/stable/bin/lein Also I can't download /leiningen-1.4.2-standalone.jar/ directly fromhttps://github.com/technomancy/leiningen/downloads, but I don't think I would know what to do with it if I could! I am a Java tyro (who knows some other lisps reasonably well) trying to use clojure under Mac Os X and Emacs, but I am having a lot of problems getting clojure to run conveniently in that environment. Thanks for your help. --Larry Travis -- 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: Problem with lazy-seq and heap space overflow
try this: (defn equal-values [seqs] Given a list of ascending sequences, returns a lazy sequence containing only values that exist in all of the sequences. (lazy-seq (if (empty? (first seqs)) [] (let [first-values (map first seqs)] (if (apply = first-values) (cons (first first-values) (equal-values (map rest seqs))) (let [min-value (apply min first-values)] (equal-values (map #(if (= (first %) min-value) (rest %) %) seqs changes: i have moved lazy-seq and replaced your recur with a call to the function that gives me: (1 40755 1533776805) hope that helps gaz 2011/1/20 Marek Stępniowski mstepniow...@gmail.com: Hi, I'm Marek Stępniowski, a Python developer trying to learn a new language by night. I'm new to this group. When solving problem 45 from Project Euler [1] I have tried to learn how lazy-seq macro should be used and wrote the code below:: (defn pentagonal-numbers [] (map #(* 1/2 % (dec (* 3 %))) (iterate inc 1))) (defn hexagonal-numbers [] (map #(* % (dec (* 2 %))) (iterate inc 1))) (defn equal-values [seqs] Given a list of ascending sequences, returns a lazy sequence containing only values that exist in all of the sequences. (if (empty? (first seqs)) [] (let [first-values (map first seqs)] (if (apply = first-values) (lazy-seq (cons (first first-values) (equal-values (map rest seqs (let [min-value (apply min first-values)] (recur (map #(if (= (first %) min-value) (rest %) %) seqs))) Unfortunately running:: (take 3 (equal-values [(pentagonal-numbers) (hexagonal-numbers)])) Results in heap space overflow exception (at max heap size = 256MB). I agree that it's a very naive solution, and that finding a third element of the list will take a lot of time. I still fail to understand why it's also needing all the memory. I'd be grateful for any pointers. What am I doing wrong here? [1] Project Euler problem 45: http://projecteuler.net/index.php?section=problemsid=45 - I find solving Project Euler problems is a good way to learn the new language, while refreshing computer science and math theory at the same time. If you're interested, you can find my git repository with 39 problems solved here: https://github.com/zuber/project-euler Thanks, -- Marek Stępniowski http://stepniowski.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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: Problem with lazy-seq and heap space overflow
interesting... the changes i suggested cause it to get the first 3 values in around 300ms on my machine and dont blow the heap O_o On Thu, Jan 20, 2011 at 8:38 PM, Ken Wesson kwess...@gmail.com wrote: My suspicion is that (lazy-seq ... (map rest seqs)) in closing over seqs causes the heads of the seqs to be held during the recur iteration. When the third value is as big as 1533776805, the recur iteration is realizing lengthy portions of the seqs downstream. The problem with this is that the lazy-seq expression that creates the closure occurs on one branch of an if and the recur on the other. A call that enters the recur therefore doesn't actually instantiate a lazy-seq object holding references to those heads. If the mere presence of the lazy-seq expression in the function makes the heads get held even on an execution path that misses the lazy-seq expression, then it may qualify as a compiler bug; after the expression (map #(if (= (first %) min-value) (rest %) %) seqs) has evaluated and recur is about to be done using the return value, the local seqs is clearable and therefore IMO should be cleared. That said, how about this implementation? (defn equal-values [seqs] (let [no-value (Object.) sentinel (Object.)] (remove #{no-value} (take-while #(not= % sentinel) (map first (iterate (fn [[rslt seqs]] (if (some empty? seqs) [sentinel [nil]] (let [fs (map first seqs) min-value (apply min fs)] [(if (apply = fs) (first fs) no-value) (map #(if (= (first %) min-value) (rest %) %) seqs)]))) [no-value seqs])) This takes about a minute on my box to produce the first three values, and doesn't blow the heap. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: [ANN] fs - file system utilities for Clojure
probably clojars.org (or by putting [fs 0.2.0-SNAPSHOT] in your project.clj if you're using lein... On Thu, Jan 13, 2011 at 7:11 AM, Tim Visher tim.vis...@gmail.com wrote: I'm missing something blindingly obvious. Where can I download this? On Wed, Jan 12, 2011 at 3:48 PM, Miki miki.teb...@gmail.com wrote: [fs 0.2.0-SNAPSHOT] is out, featuring: abspath Return absolute path basename Return the last part of path copy Copy a file cwd Return the current working directory delete Delete path directory? True if path is a directory dirname Return directory name executable? Check if path is executable exists? Check if path exists file? True if path is a file glob `ls` like operator join Join part to path listdir List files under directory mkdir Create directory mtime File modification time mkdirs Create directory tree normpath Return normalized (canonical) path readable? Check if path is readable rename Rename path separator Path separator size File size split Split path to parts tempdir Create temporary directory tempfile Create temporary file walk Walk over directory structure, calling function on every step writeable? Check if path is writable Have fun, -- Miki -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: [ANN] fs - file system utilities for Clojure
there is also this: https://github.com/jashmenn/clj-file-utils which seems to be very similar On Thu, Jan 13, 2011 at 9:04 AM, Steve Miner stevemi...@gmail.com wrote: Thanks for shaing. I was just about to write several functions along these lines. I have a couple of comments. First, I suggest that you look at the standard clojure.java.io package for some useful functions that are already in Clojure 1.2. In particular, you could use io/file instead of (File. xxx) in your code to add some flexibility to the kinds of things that can be treated as a file. I think io/file could replace your fs/join. Also, io/copy is very flexible so it's worth a look, too. Second, fs is using a singe segment namespace. I remember that there have been some cautions against doing that. (But not everyone agrees.) My understanding is that it's best for Java interop to have a multi-segment namespace. (Reference links below.) http://clojure.org/libs A lib name is a symbol that will typically contain two or more parts separated by periods. http://groups.google.com/group/clojure-dev/browse_frm/thread/00b1c6971c3b3394 Chas Emerick wrote: First, namespacing is good. Your foobar library won't have the same name as my foobar library -- and while you might think who else would put code in the same oddly-named namespace as mine?, it's a big world out there and an ounce of prevention is worth a pound of cure. More strictly speaking, one cannot use any class in the default package from any Java class that is in a package. That is the practical issue that leads to default package use being nonexistent in the Java space. And, you may not care about Java interop now, but either (a) you might later, or (b) your users might, now. Finally, gen-class will simply not work (last I checked) from a single-segment namespace. Best Regards, Steve Miner stevemi...@gmail.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 regexs
i think you want to do something like this: (let [_ year month day] (re-find date-regex line)) On Thu, Jan 13, 2011 at 8:50 PM, Eric Lavigne lavigne.e...@gmail.com wrote: So I am converting some Ruby code I have into CLojure for practice/fun and I am having trouble finding info via Google. Clojure uses the same regex style as Java, so you'll need to search for information on Java regexes rather than Clojure regexes. -- 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