Re: Windows Installation
As Jonathan Friberg says - lein.bat works fine. As Windows seems to often go hand-in-hand with intrusive proxies, you might also want to make sure you have environment variables HTTP_PROXY and HTTPS_PROXY pointing to a working proxy, if necessary you can run your own proxy using cntlm : http://cntlm.sourceforge.net/ We've also had a lot of success using Vagrant to run virtual headless Linux machines, and then sharing the development directories with Windows to run IDEs and the like. This gives you a real linux environment, rather than the cobbled together mess you get with cygwin or gow or msys; it also means you can check in all your machine configurations into version control and make sure that every (virtual) development PC is identical. I'd highly recommend this if you have a team that are happier in a linux environment than a Windows one. - Korny On 9 March 2013 14:55, James Ashley james.ash...@gmail.com wrote: Since I've seen a few recent posts about this experience, I figured I'd share mine: 0a) Install cygwin. I don't understand how any programmer stuck using windows can get by without it 1) Install the Oracle JDK 1a) Add javac to my PATH (I added a symbolic link to javac.exe inside cygwin in a directory that was already in my PATH: ~/bin) 2) Download the lein install script as text from the leiningen home page. 3) Copy it over to my cygwin directory 4) Search/replace to replace the HTML entities with the real thing. I think this was a matter of amp; and gt; 5) It was already executable, so just run it (naming it lein.sh rather than lein.bat was important). I got errors about certificates and permissions. They mentioned instructions about setting up an environment variable (something about something like `export DOWNLOAD=curl --trusting %1`...that wasn't it, but it was along the same lines). I believe that it's some weirdness in the account settings (I have other issues along the same lines in totally unrelated packages), but I suppose I could have just installed some horrible virus. Oh, well. 6) Create a new project 7) Change project.clj to use clojure 1.5 8) `lein repl` inside cygwin didn't work correctly. CLASSPATH was all windows-style, which confused cygwin. So basic clojure.core pieces weren't found. 8a) I suspect I could have set up, say, powershell, to make this work. But that's stupid, and I don't have time to waste on it. 9) nrepl-jack-in inside emacs worked fine. 9a) I'm using an init.el from other systems that already have clojure set up. But there isn't anything fancy or special or customized about it. Just standard configuration stuff that I've found on bare-minimal blog posts 10) Add a symlink to lein in ~/bin. I guess that probably looks big and scary. Windows users are used to a pretty GUI that they ignore and click Next a lot. I dont have a lot of sympathy. I haven't done anything meaningful here at all. But the bare-bones part of the installation process Just Worked. Thank you *so* much to all the people who have worked so hard to make this as simple as it is! Respectfully, James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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. -- Kornelis Sietsma korny at my surname dot com http://korny.info We do not quit playing because we grow old, we grow old because we quit playing - O.W. Holmes -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Windows Installation
I've made installers for clojure-based programs using InnoSetup before, and wouldn't mind doing it if people think it is a good idea. There would be a few choices around Java... a) Assume that a JDK is installed b) Check for java and direct the user to Oracle's site to download JDK 7 if it is missing c) Bundle an embedded JRE + JDK redistributables (If we haven't bundled a JDK we'd need to ensure that the JDK bin directory is on the path, else javac won't work) -- Dave On Sat, Mar 9, 2013 at 4:28 PM, Brent Millare brent.mill...@gmail.comwrote: Does anyone see value in a wizard for lein? Does anyone know how to write a wizard, preferably with a scripting language, or xml, rather than c++? And can you alter system variables from within the wizard? On Saturday, March 9, 2013 8:18:44 AM UTC-5, BJG145 wrote: As long as you have wget, that works fine. Only problem I've found so far is that lein new app followed by lein check throws an error, but it looks like people are on the case. https://github.com/**technomancy/leiningen/issues/**863https://github.com/technomancy/leiningen/issues/863 On Saturday, March 9, 2013 11:24:04 AM UTC, Jonathan Fischer Friberg wrote: My experience: 1. Download lein.bat 2. Run it Jonathan On Sat, Mar 9, 2013 at 10:23 AM, BJG145 benmag...@gmail.com wrote: Perhaps this general anti-Windows attitude is what Windows-based newcomers to Clojure find off-putting... On Saturday, March 9, 2013 3:55:59 AM UTC, James Ashley wrote: Since I've seen a few recent posts about this experience, I figured I'd share mine: 0a) Install cygwin. I don't understand how any programmer stuck using windows can get by without it 1) Install the Oracle JDK 1a) Add javac to my PATH (I added a symbolic link to javac.exe inside cygwin in a directory that was already in my PATH: ~/bin) 2) Download the lein install script as text from the leiningen home page. 3) Copy it over to my cygwin directory 4) Search/replace to replace the HTML entities with the real thing. I think this was a matter of amp; and gt; 5) It was already executable, so just run it (naming it lein.sh rather than lein.bat was important). I got errors about certificates and permissions. They mentioned instructions about setting up an environment variable (something about something like `export DOWNLOAD=curl --trusting %1`...that wasn't it, but it was along the same lines). I believe that it's some weirdness in the account settings (I have other issues along the same lines in totally unrelated packages), but I suppose I could have just installed some horrible virus. Oh, well. 6) Create a new project 7) Change project.clj to use clojure 1.5 8) `lein repl` inside cygwin didn't work correctly. CLASSPATH was all windows-style, which confused cygwin. So basic clojure.core pieces weren't found. 8a) I suspect I could have set up, say, powershell, to make this work. But that's stupid, and I don't have time to waste on it. 9) nrepl-jack-in inside emacs worked fine. 9a) I'm using an init.el from other systems that already have clojure set up. But there isn't anything fancy or special or customized about it. Just standard configuration stuff that I've found on bare-minimal blog posts 10) Add a symlink to lein in ~/bin. I guess that probably looks big and scary. Windows users are used to a pretty GUI that they ignore and click Next a lot. I dont have a lot of sympathy. I haven't done anything meaningful here at all. But the bare-bones part of the installation process Just Worked. Thank you *so* much to all the people who have worked so hard to make this as simple as it is! Respectfully, James -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com For more options, visit this group at http://groups.google.com/**group/clojure?hl=enhttp://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+u...@googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://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
Re: Composable mutual recursive function composition
What´s Prismatic for ? Why do you build graphs of computation ? Thanks 2013/3/10 Brent Millare brent.mill...@gmail.com I recently asked about mutual referenced support in the prismatic library plumbing https://github.com/Prismatic/plumbing and currently its an open question about how to implement that. So I made a proof-of-concept version of a graph-like library that supports mutual recursion. https://github.com/bmillare/dj.compose Note some differences: * fnb are higher order functions, so its expected you use it to wrap an existing anonymous function * functions in the bind-map are just plain functions and accept any number of arguments. They are not map oriented. I encourage those interested to the read the sources, its only 1 macro, and 1 function. Feedback appreciated. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Composable mutual recursive function composition
I see now the blog post. Thanks anyway 2013/3/10 Catonano caton...@gmail.com What´s Prismatic for ? Why do you build graphs of computation ? Thanks 2013/3/10 Brent Millare brent.mill...@gmail.com I recently asked about mutual referenced support in the prismatic library plumbing https://github.com/Prismatic/plumbing and currently its an open question about how to implement that. So I made a proof-of-concept version of a graph-like library that supports mutual recursion. https://github.com/bmillare/dj.compose Note some differences: * fnb are higher order functions, so its expected you use it to wrap an existing anonymous function * functions in the bind-map are just plain functions and accept any number of arguments. They are not map oriented. I encourage those interested to the read the sources, its only 1 macro, and 1 function. Feedback appreciated. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: :use an entire namespace full of protocols or stick with :require?
Isn't it true that you must *import* those protocols, and not :use them? In that case your dilemma would be moot. On Thursday, February 14, 2013 2:26:50 PM UTC+1, Jim foo.bar wrote: I know that using a bare :use in the ns macro is generally frowned upon as it provides no hints about what is actually being used... However, I 've got 2 namespaces 'abstractions.clj' and 'concretions.clj'...concretions.clj will eventually use all the protocols defined in abstractions.clj...at the moment it doesn't but as I work through it I want to provide concrete records for *all* the protocols... Should I just go and :use the entire thing or should I stick with :require and keep typing 'pro/XXX' a million times? That specific namespace is very central to my work... Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: :use an entire namespace full of protocols or stick with :require?
no I don't have to :import them...I need the namespace loaded and then I need access to all the protocol vars (both can be achieved with :require)...The concrete records need importing by the consumer, if that's what you mean... Jim On 10/03/13 11:18, Marko Topolnik wrote: Isn't it true that you must /import/ those protocols, and not :use them? In that case your dilemma would be moot. On Thursday, February 14, 2013 2:26:50 PM UTC+1, Jim foo.bar wrote: I know that using a bare :use in the ns macro is generally frowned upon as it provides no hints about what is actually being used... However, I 've got 2 namespaces 'abstractions.clj' and 'concretions.clj'...concretions.clj will eventually use all the protocols defined in abstractions.clj...at the moment it doesn't but as I work through it I want to provide concrete records for *all* the protocols... Should I just go and :use the entire thing or should I stick with :require and keep typing 'pro/XXX' a million times? That specific namespace is very central to my work... Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: :use an entire namespace full of protocols or stick with :require?
On 09/03/13 23:00, Korny Sietsma wrote: Note that as of clojure 1.4 you can also do: (:require foo.bar :refer :all) in fact from comments I've seen elsewhere there is a general intention to remove :use entirely? a bare :use is essentially the same thing as :require :refer :all...none gives any insight about what is being brought in...my understanding is that since they do the same (bad) thing, let's stop using one of them... so given this, my question can be re-phrased as :use/[:require :refer:all] an entire namespace full of protocols or stick with [:require :as]?... Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: :use an entire namespace full of protocols or stick with :require?
On 09/03/13 23:09, Travis Vachon wrote: Speaking strictly for myself, but as someone who spends about half his professional day writing Clojure: :use is dead, long live :require. I've found using :require [foo :refer :all] rather than :use foo has lead to cleaner, more consistent ns statements in my own code, and I've made it a policy to convert old :use statements to :refer :all whenever possible. I've done the same thing and the ns declarations do look cleaner...however, a cleaner ns declaration says nothing about what vars you're bringing in. I could argue that :use :only is a lot better than :require :refer :allin other words, burying :use doesn't mean that suddenly :require :refer :all is good...it is equally bad as a bare :use... in my case though, I will most likely use all the vars (eventually), hence my question... Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: :use an entire namespace full of protocols or stick with :require?
I came to prefer one-letter prefix for a common ns over no prefix at all. Once you get accustomed to it, prefixless fns start looking wrong, and the overhead of two chars is something we can live with. On Sunday, March 10, 2013 12:50:57 PM UTC+1, Alex Baranosky wrote: Stick with require/as. You'll love yourself more in a few months when you need to read it. :) On Sun, Mar 10, 2013 at 4:48 AM, Jim - FooBar(); jimpi...@gmail.comjavascript: wrote: On 09/03/13 23:00, Korny Sietsma wrote: Note that as of clojure 1.4 you can also do: (:require foo.bar :refer :all) in fact from comments I've seen elsewhere there is a general intention to remove :use entirely? a bare :use is essentially the same thing as :require :refer :all...none gives any insight about what is being brought in...my understanding is that since they do the same (bad) thing, let's stop using one of them... so given this, my question can be re-phrased as :use/[:require :refer:all] an entire namespace full of protocols or stick with [:require :as]?... Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@**googlegroups.com javascript: For more options, visit this group at http://groups.google.com/**group/clojure?hl=enhttp://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+u...@**googlegroups.com javascript:. For more options, visit https://groups.google.com/**groups/opt_outhttps://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: :use an entire namespace full of protocols or stick with :require?
On 10/03/13 12:03, Marko Topolnik wrote: I came to prefer one-letter prefix for a common ns over no prefix at all. Once you get accustomed to it, prefixless fns start looking wrong, and the overhead of two chars is something we can live with. yes I agree with you 100%...this is my approach as well for 'useful' namespaces...for example a hypothetical utilities.clj is good if it's aliased uniformly across namespaces as 'ut'...do you do the same with your abstractions? do you always alias your protocols.clj? my question is specific to protocols as they will only be used in a couple of places, mainly in the 'concretions' namespace...to be honest, at the moment I'm using :refer :all simply because I'd need the characters 'pro/' more than 300 times in that namespace...it would actually make readability worse in my opinion... Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Model-View-Controller in Clojure?
Not all of your application can be purely functional, because it inevitably needs to interact with the outside world at some point. Purely functional code is easier to reason about, so the pragmatic approach of Clojure is to encourage you to have most of your application be purely functional, while not getting too much in the way when you actually need mutation (and trying to provide a sane way to control these mutations via its reference types). Your state will/should be an immutable data structure, and the evolutions of this state across time (or in reaction to user input) should be controlled by purely functional transformations. The boundaries of the system, however, will not be functional. One way to approach MVC in Clojure would be to have a pure function that transforms your model into the next one based on external input, and another function which, taking your model as a parameter, creates or updates the view. This can be implemented with watchers : Clojure reference types can have watchers associated to them, which are called every time the reference changes. Depending on your concurrency needs, you could potentially implement a sort-of MVC pattern with a single atom to control the whole state of your application. On 9 March 2013 15:30, Jim - FooBar(); jimpil1...@gmail.com wrote: also see this for a discussion about why the need for design patterns almost disappears in Clojure: http://stackoverflow.com/questions/8902113/clojure-model-view-controller-mvc-design Jim On 09/03/13 14:24, Jim - FooBar(); wrote: You need to store your model in a ref-type (atom,agent,or ref), and attach a watcher on it (a fn which is responsible for updating the view). Now, 'mutating' your model will trigger a View update...piece of cake :) example: (def board-history Log of the state of a game. (atom [])) (defn log-board The logging function for the board ref. Will conj every new board-state into a vector. [dest k r old n] (when-not (= n old) (swap! dest conj n))) (def current-chessItems This is list that keeps track of moving chess pieces. Is governed by an atom and it changes after every move. All changes are being logged to 'board-history'. Starts off as nil but we can always get the initial board arrangement from core. (- (atom nil) (add-watch :log (partial core/log-board core/board-history) HTH, Jim ps: my example does not involve GUI, but you get the idea...it it trivial to change the code so that it 'repaints' the canvas with the new board instead of conjing it On 09/03/13 14:11, edw...@kenworthy.info wrote: So I understand that Clojure's data structures are immutable but I am not clear how that works with MVC. So I have a view that displays a model. Other processes change that model and the View presents those changes. However it's not clear to me how that would work with an immutable model. Obviously I can't pass the model into the View, have the view store a reference to it and each time it's called on to render the model, do so. The model is immutable. So I could have a global variable which points to the model, and whenever I 'change' the model I re-point it to the updated version. Obviously the view would have to reference that global. This just smells bad. And would get worse for each model and view you needed in your application. I suppose you could maintain some global map of models, but that doesn't look nice either, it's not that much different from having a pile of global models. This must be a solved problem surely? Could someone point me to the solution please? Swing or Quil based would be fine but I assume it must be generally applicable. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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
Re: :use an entire namespace full of protocols or stick with :require?
From experience in your case (300+) I'd use require/as with a small prefer like p/ . On Sun, Mar 10, 2013 at 5:10 AM, Jim - FooBar(); jimpil1...@gmail.comwrote: On 10/03/13 12:03, Marko Topolnik wrote: I came to prefer one-letter prefix for a common ns over no prefix at all. Once you get accustomed to it, prefixless fns start looking wrong, and the overhead of two chars is something we can live with. yes I agree with you 100%...this is my approach as well for 'useful' namespaces...for example a hypothetical utilities.clj is good if it's aliased uniformly across namespaces as 'ut'...do you do the same with your abstractions? do you always alias your protocols.clj? my question is specific to protocols as they will only be used in a couple of places, mainly in the 'concretions' namespace...to be honest, at the moment I'm using :refer :all simply because I'd need the characters 'pro/' more than 300 times in that namespace...it would actually make readability worse in my opinion... Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/**group/clojure?hl=enhttp://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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com . For more options, visit https://groups.google.com/**groups/opt_outhttps://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: Model-View-Controller in Clojure?
On 10/03/13 12:32, Gary Verhaegen wrote: Not all of your application can be purely functional, because it inevitably needs to interact with the outside world at some point. yes that is true...however, I often find that my first impression of what the functional boundaries are, is not necessarily the correct one...for example, when I started writing my board-game engine, I was pretty sure that when the time comes to code chess I'd need side-effects to achieve castling and en-passant moves (because they depend on other pieces and their state). At the time I was pretty happy introducing limited side effects. Having finished my engine ,and after having coded fully functional implementations of chess, checkers and tic-tac-toe I can confirm that I did not need side effects anywhere other than showing stuff on screen and talking to the disk (for saving-loading games). Absolutely nothing! Both castling and en-passant can be coded with the help of meta-data and a specialised mover (a higher order fn) for such occasions...nothing more - nothing less! it wasn't immediately apparent how - but it was indeed possible and in fact very elegant! of course, now you will ask : 'how is performance in such a purely functional and cpu-intensive game?' Well, I don't have a good answer for that until I manage to add pruning to my parallel minimax. at the moment and after numerous optimizations, I can do an exhaustive search down to level 4 usually in less than 8sec with an average branching factor of 26. In the best case, pruning can cut this down in half which sounds pretty impressive if I ever manage it! Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Namespaced symbols, and errors
Here's another mental model that you can use. (Not sure it is 100% accurate with the actual implementation, but it has served me well so far.) Keywords are not bound, in the same sense that numbers are not bound. 1 is 1, just as 2 is 2, whatever the namespace you are into. 1 from the user namespace is the same a 1 from the clojure.core namespace. Similarly, the keyword :hello is not bound, it just is. :hello in the user namespace is the same value as :hello in the core namespace or in any other namespace. As keywords are very lightweight to create and very fast to compare for equality, they are often used as keys in associative data structures. Sometimes, though, you actually want to have keywords that are local to your namespace, because you want to encapsulate some behaviour. Say you want to create a simple tree-manipulation library, where your nodes are, for some reason, represented as maps with a special key :children. Other than that, you want the user of your library to be able to add any information to the maps representing the nodes of the tree. One way to approach this would be to document that the special key :children is reserved and cannot be used. Another way to handle this would be to create a keyword that is supposedly unique to your library, by prefixing the keyword with some chosen prefix, say :tree-children. That would soon become quite cumbersome to type, and does not really preclude the preceding point, though it would make conflicts rarer. But there is one thing that Clojure can guarantee, which is that in a single application, there will not be two namespaces with the same name. So, assuming your library is contained in a namespace called my.tree-manipulation.core, you could decide to call your special key :my.tree-manipulation.core.children. That, too, would be cumbersome, but conceivably safer. Now, this is originally an implementation detail, but it just so happens that keywords are basically implemented as symbols that evaluate to themselves. That is, if keywords did not exist in Clojure, you could invent them by declaring them as (def :a ':a); after that declaration, :a would work exactly like a keyword works today in Clojure. Which means that we can reuse the namespace resolution feature of symbols : every time the reader reads in a symbols, it first resolves it in the current namespace, and then evaluates the full symbol to find its value. Keywords sort of short-circuit that by default. However, with the :: notation, you are basically telling the reader to first evaluate the given symbol in the current namespace, then evaluate it as a symbol. So ::bla in namespace test is the same as typing the full keyword :test/bla. But the keyword itself is not resolved in the namespace, the keyword just is. It just so happens that its value looks like a namespace-qualified symbol with a colon in front. Getting back to the tree example, you can thus have your special key be ::children, which combines the two following advantages : the actual keyword is pretty specific to your library, as the real keyword seen by the compiler will be :my.tree-manipulation.core/children, but it is also nearly as short to type and to read as plain :children. Now let's look at your questions in light of this mental model. On 9 March 2013 19:37, nick rothwell n...@cassiel.com wrote: I understand that ::foo is a keyword bound into the local namespace. So ::foo is actually a shorthand for the :my.ns/foo keyword, which is a value by itself, independently of any enclosing or existing namespace. (Keywords follow the symbol rule of maximum one / in the name, but there is actually no link with existing namespaces : you can use a keyword :no-namespace/k even if there is no namespace called no-namespace.) I also understand (according to the docs) that :my.namespace/foo is the keyword foo in the namespace my.namespace. As I stated earlier, namespaces are only of interest to symbol resolution; they do not interfere with keywords beyond their optional construction via the :: shorthand. ::nsalias/foo is the keyword foo in the namespace my.namespace if I've aliased my.namespace to nsalias. So Clojure first tries to find the corresponding symbol, then only converts it to a keyword. Thus namespace resolution works with aliases. The resulting keyword is still a value by itself. But also: ::my.namespace/foo is equivalent to :my.namespace/foo (as a convenience, I guess). Resolving an already namespace-qualified symbol yields the same namespace-qualified symbol. :nsalias/foo is not the same as ::nsalias/foo - in fact, I'm not sure what :nsalias/foo is - a call on str yields :nsalias/foo. :nsalias/foo is the value :nsalias/foo - symbols are self-evaluating values, just as 1 is 1. The fact that it looks like a namespaced symbol is irrelevant. ::nsalias/foo is asking the reader to first resolve the symbol nsalias/foo in the current namespace, using known aliases if need be, and only afterwards turning it
Re: Newbie requesting review
Your code looks fine to me. One alternative for make-students would have been (defn make-students [teacherName n] (map #(make-student teacherName (make-student-name %) 0) (range n))) In case you're not familiar with it, the #() notation creates an anonymous function in the same way as (fn [_]), but a bit shorter; the arguments to the function are %, %2, %3, etc.; the first argument may also be %1. The arity of the anonymous function is determined by the arguments that appear in its expression. This is thus still creating a closure, but it is using it immediately. On 9 March 2013 23:49, Craig Ching craigch...@gmail.com wrote: Hi all, I wrote some code to generate some example data for a web ui that I'm working on and I was wondering if I could get some advice about it to ensure I'm on the right track in my clojure learning. Basically its a very simple program that generates a number of JSON files that contain information, I've modeled the problem as a teacher-student relationship where each teacher is a file that contains data about a number of students. The inputs to the main function (gen) takes the number of teachers and the number of students per teacher and generates sample data that can be consumed by the web ui. What I'm looking for is: 1. Am I doing things the clojure way, is my program idiomatic? If not, advice is appreciated. 2. Specifically the main function in the program (make-student-factory) I've modeled as a closure and I feel like there is probably a better way to do it, what are your thoughts on that? Here is the code: (ns teachers.core (:require [clj-json.core :as json])) (defn- gen-items-json [students] (json/generate-string {timestamp 5000 items students identifier id label id rc 200 msg Data retrieved successfully.})) (defn- make-student [teacherName studentName age] {id (str teacherName ! studentName) TeacherName teacherName StudentName studentName age age}) (defn- make-name [prefix n] (str prefix n)) (defn- make-teacher-name [n] (make-name TEACHER n)) (defn- make-student-name [n] (make-name STUDENT n)) (defn- make-student-factory Returns a function allowing you to create a number of student definitions for the given teacher. [teacherName] (fn [n] (make-student teacherName (make-student-name n) 0))) (defn- make-students [teacherName n] (let [fac (make-student-factory teacherName)] (map fac (range n (defn- spit-json [teacherName n] (println Creating n students for teacher: teacherName) (spit (str teacherName .json) (gen-items-json (make-students teacherName n (defn gen [numTeachers numStudents] (doseq [teacherName (map make-teacher-name (range numTeachers))] (spit-json teacherName numStudents))) Thanks for any comments! Cheers, Craig -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Model-View-Controller in Clojure?
My approach to this was to build a GUI framework which facilitates the use of closures to capture all the state atoms. This avoids the global map. The downside of global maps is also the limitation to singletons: if the same GUI element were created twice, name clashes in the global map would be the result. On Saturday, March 9, 2013 3:11:53 PM UTC+1, edw...@kenworthy.info wrote: So I understand that Clojure's data structures are immutable but I am not clear how that works with MVC. So I have a view that displays a model. Other processes change that model and the View presents those changes. However it's not clear to me how that would work with an immutable model. Obviously I can't pass the model into the View, have the view store a reference to it and each time it's called on to render the model, do so. The model is immutable. So I could have a global variable which points to the model, and whenever I 'change' the model I re-point it to the updated version. Obviously the view would have to reference that global. This just smells bad. And would get worse for each model and view you needed in your application. I suppose you could maintain some global map of models, but that doesn't look nice either, it's not that much different from having a pile of global models. This must be a solved problem surely? Could someone point me to the solution please? Swing or Quil based would be fine but I assume it must be generally applicable. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Newbie requesting review
Several comments: 1. camelCase is not idiomatic for Clojure. Prefer lowercase-dashed-style. 2. use :keywords for map keys and, more generally, for any enumeration-type values (coming from a closed set of options). If you want JSON output, transform these into camelCased strings only at the checkout desk. 3. make-student-factory is what you'd call a *curried* function. You'd have an easier time with it if you declared it as a regular two-argument function and then used either clojure.core/partial or a literal #(make-student teacher-name %). That would allow you to use the function either directly as a student factory, or as a factory of student factories. Note that your approach to use a closure *is *idiomatic, I'm just advising a more idiomatic way to get it. On Saturday, March 9, 2013 11:49:26 PM UTC+1, Craig Ching wrote: Hi all, I wrote some code to generate some example data for a web ui that I'm working on and I was wondering if I could get some advice about it to ensure I'm on the right track in my clojure learning. Basically its a very simple program that generates a number of JSON files that contain information, I've modeled the problem as a teacher-student relationship where each teacher is a file that contains data about a number of students. The inputs to the main function (gen) takes the number of teachers and the number of students per teacher and generates sample data that can be consumed by the web ui. What I'm looking for is: 1. Am I doing things the clojure way, is my program idiomatic? If not, advice is appreciated. 2. Specifically the main function in the program (make-student-factory) I've modeled as a closure and I feel like there is probably a better way to do it, what are your thoughts on that? Here is the code: (ns teachers.core (:require [clj-json.core :as json])) (defn- gen-items-json [students] (json/generate-string {timestamp 5000 items students identifier id label id rc 200 msg Data retrieved successfully.})) (defn- make-student [teacherName studentName age] {id (str teacherName ! studentName) TeacherName teacherName StudentName studentName age age}) (defn- make-name [prefix n] (str prefix n)) (defn- make-teacher-name [n] (make-name TEACHER n)) (defn- make-student-name [n] (make-name STUDENT n)) (defn- make-student-factory Returns a function allowing you to create a number of student definitions for the given teacher. [teacherName] (fn [n] (make-student teacherName (make-student-name n) 0))) (defn- make-students [teacherName n] (let [fac (make-student-factory teacherName)] (map fac (range n (defn- spit-json [teacherName n] (println Creating n students for teacher: teacherName) (spit (str teacherName .json) (gen-items-json (make-students teacherName n (defn gen [numTeachers numStudents] (doseq [teacherName (map make-teacher-name (range numTeachers))] (spit-json teacherName numStudents))) Thanks for any comments! Cheers, Craig -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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.
[ANN] clj-configurator – A powerful yet simple Clojure configuration library.
Hello everyone! I made a little configuration library: https://github.com/myfreeweb/clj-configurator Supports any configuration format (TOML, YAML, JSON, EDN, whatever) -- you just parse it yourself. Supports environment variables and Java system properties. Automatically figures out types based on defaults. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Namespaced symbols, and errors
On Friday, March 8, 2013 4:56:03 PM UTC+1, nick rothwell wrote: Typing the following at a REPL: (str ::junk/junk) (where there's no alias for junk) gives me: RuntimeException Invalid token: ::junk/junk clojure.lang.Util.runtimeException (Util.java:219) RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException (Util.java:219) A couple of things: (i) Invalid token seems a bit curt: doesn't it mean something like no such namespace alias? This could definitely benefit from an improvement in the reader/compiler. Another aside: why does Clojure require :: for aliases but only : for namespace-qualified keywords? Under what circumstance would I use :junk/junk in any way other than to mean ::junk/junk (or :my.namespace.junk/junk, given the appropriate alias)? ::keyword being a shortcut for ::current-ns/keyword is more consistent (so less surprising) than being a shortcut for :current-ns/keyword. String value of a keyword is often important and dictated by outside constraints (conversion from/to string is common) so there's benefit to allowing a slash in it. I personally appreciate the :: to signal a qualified keyword. They are rare and special so it's nice to have them visually stand out. I bet other people can enumerate other reasons to support/criticise this design choice, but in the end there won't be much to learn from it. -Marko -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Model-View-Controller in Clojure?
Thanks very much Jim, that's really useful stuff. On Saturday, March 9, 2013 2:30:59 PM UTC, Jim foo.bar wrote: also see this for a discussion about why the need for design patterns almost disappears in Clojure: http://stackoverflow.com/questions/8902113/clojure-model-view-controller-mvc-design Jim On 09/03/13 14:24, Jim - FooBar(); wrote: You need to store your model in a ref-type (atom,agent,or ref), and attach a watcher on it (a fn which is responsible for updating the view). Now, 'mutating' your model will trigger a View update...piece of cake :) example: (def board-history Log of the state of a game. (atom [])) (defn log-board The logging function for the board ref. Will conj every new board-state into a vector. [dest k r old n] (when-not (= n old) (swap! dest conj n))) (def current-chessItems This is list that keeps track of moving chess pieces. Is governed by an atom and it changes after every move. All changes are being logged to 'board-history'. Starts off as nil but we can always get the initial board arrangement from core. (- (atom nil) (add-watch :log (partial core/log-board core/board-history) HTH, Jim ps: my example does not involve GUI, but you get the idea...it it trivial to change the code so that it 'repaints' the canvas with the new board instead of conjing it On 09/03/13 14:11, edw...@kenworthy.info javascript: wrote: So I understand that Clojure's data structures are immutable but I am not clear how that works with MVC. So I have a view that displays a model. Other processes change that model and the View presents those changes. However it's not clear to me how that would work with an immutable model. Obviously I can't pass the model into the View, have the view store a reference to it and each time it's called on to render the model, do so. The model is immutable. So I could have a global variable which points to the model, and whenever I 'change' the model I re-point it to the updated version. Obviously the view would have to reference that global. This just smells bad. And would get worse for each model and view you needed in your application. I suppose you could maintain some global map of models, but that doesn't look nice either, it's not that much different from having a pile of global models. This must be a solved problem surely? Could someone point me to the solution please? Swing or Quil based would be fine but I assume it must be generally applicable. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com javascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: 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+u...@googlegroups.com javascript:. 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.
Clojure 1.5.1
Clojure 1.5.1 fixes a memory leak in Clojure 1.5, discussed here: https://groups.google.com/d/msg/clojure-dev/uAFM0Ti4AcQ/GmnKmphF1BgJ Getting Clojure: Web: http://clojure.org/downloads Lein/Maven: :dependencies [[org.clojure/clojure 1.5.1]] Note that it will take a few hours for the links above to become live, as the completed build moves into Maven Central. Thanks, Stu Halloway Clojure/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 --- 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: :use an entire namespace full of protocols or stick with :require?
I would say using :require :as is in almost all cases better. However, I think :use is preferred if almost everything done in the current namespace depends on the used namespace. Though, no more than one namespace should ever be imported with :use in the same namespace. In your case I think it's acceptable to :use the namespace with protocols - but no more. Also, :use :only is to be avoided almost as much as :use. I tend to use :use :only for common functions that are not in core. clojure.java.io/resource being the most common one. Jonathan On Sun, Mar 10, 2013 at 1:40 PM, Alex Baranosky alexander.barano...@gmail.com wrote: From experience in your case (300+) I'd use require/as with a small prefer like p/ . On Sun, Mar 10, 2013 at 5:10 AM, Jim - FooBar(); jimpil1...@gmail.comwrote: On 10/03/13 12:03, Marko Topolnik wrote: I came to prefer one-letter prefix for a common ns over no prefix at all. Once you get accustomed to it, prefixless fns start looking wrong, and the overhead of two chars is something we can live with. yes I agree with you 100%...this is my approach as well for 'useful' namespaces...for example a hypothetical utilities.clj is good if it's aliased uniformly across namespaces as 'ut'...do you do the same with your abstractions? do you always alias your protocols.clj? my question is specific to protocols as they will only be used in a couple of places, mainly in the 'concretions' namespace...to be honest, at the moment I'm using :refer :all simply because I'd need the characters 'pro/' more than 300 times in that namespace...it would actually make readability worse in my opinion... Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/**group/clojure?hl=enhttp://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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com . For more options, visit https://groups.google.com/**groups/opt_outhttps://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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Windows Installation
On Sat, Mar 9, 2013 at 12:37 PM, BJG145 benmagicf...@gmail.com wrote: (...I have to say that, from reading the above, Cygwin sounds like a nighmare and I certainly won't be troubling it...! If you want Linux on a Windows machine, Virtualbox sounds like a safer bet...) Installing GOW Gnu on Windows seems to be a much more lightweight way of achieving a similar goal: getting the most common *nix utilities running at the Windows command line. https://github.com/bmatzelle/gow/wiki It provides curl and wget so it makes Leiningen a breeze to install. -- 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.
Problem with Code Dispatch for Anonymous Functions?
Could anyone help me understand why the following code is breaking? (require '[clojure.pprint :refer [with-pprint-dispatch code-dispatch pprint]]) (with-pprint-dispatch code-dispatch (pprint (read-string (^:once fn* [x] x IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol clojure.lang.RT.seqFrom (RT.java:505) #( The #( is not a typo. It starts to print and then fails. Looking at the code, it looks like there's an issue here: (defn- pprint-anon-func [alis] (let [args (second alis) nlis (first (rest (rest alis)))] (if (vector? args) (binding [*symbol-map* (if (= 1 (count args)) {(first args) %} (into {} (map #(vector %1 (str \% %2)) args (range 1 (inc (count args))] ((formatter-out ~#(~;~@{~w~^ ~_~}~;)~:) nlis)) (pprint-simple-code-list alis I squinted at it for a bit, but I'm not sure what's up. Anyone have any ideas? Thanks, -- '(Devin Walters) -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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.
type inference in core.logic
I feel as though I've seen a comprehensive tutorial involving type inference in core.logic. I've recently been looking through the links referred to in this posthttps://groups.google.com/forum/?fromgroups=#!searchin/clojure/core.logic$20type$20inference/clojure/Ioits6npTcs/OWNYNUQVTNgJ, however I'm finding them a little hard to follow. I feel as though I've seen another tutorial somewhere. If anyone has information on this, it would be appreciated. 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.
Re: :use an entire namespace full of protocols or stick with :require?
I switched to just using (:require) with :as and :refer unless there's a really good reason to use :use. It stops me from accidentally making the mistake of dropping [my.ns.core :as foo] into a growing (ns (:use …)) form. -- '(Devin Walters) On Sunday, March 10, 2013 at 3:03 PM, Jonathan Fischer Friberg wrote: I would say using :require :as is in almost all cases better. However, I think :use is preferred if almost everything done in the current namespace depends on the used namespace. Though, no more than one namespace should ever be imported with :use in the same namespace. In your case I think it's acceptable to :use the namespace with protocols - but no more. Also, :use :only is to be avoided almost as much as :use. I tend to use :use :only for common functions that are not in core. clojure.java.io/resource (http://clojure.java.io/resource) being the most common one. Jonathan On Sun, Mar 10, 2013 at 1:40 PM, Alex Baranosky alexander.barano...@gmail.com (mailto:alexander.barano...@gmail.com) wrote: From experience in your case (300+) I'd use require/as with a small prefer like p/ . On Sun, Mar 10, 2013 at 5:10 AM, Jim - FooBar(); jimpil1...@gmail.com (mailto:jimpil1...@gmail.com) wrote: On 10/03/13 12:03, Marko Topolnik wrote: I came to prefer one-letter prefix for a common ns over no prefix at all. Once you get accustomed to it, prefixless fns start looking wrong, and the overhead of two chars is something we can live with. yes I agree with you 100%...this is my approach as well for 'useful' namespaces...for example a hypothetical utilities.clj is good if it's aliased uniformly across namespaces as 'ut'...do you do the same with your abstractions? do you always alias your protocols.clj? my question is specific to protocols as they will only be used in a couple of places, mainly in the 'concretions' namespace...to be honest, at the moment I'm using :refer :all simply because I'd need the characters 'pro/' more than 300 times in that namespace...it would actually make readability worse in my opinion... Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com (mailto:clojure@googlegroups.com) Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com (mailto:clojure%2bunsubscr...@googlegroups.com) For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com (mailto:clojure%2bunsubscr...@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 (mailto:clojure@googlegroups.com) Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com (mailto:clojure%2bunsubscr...@googlegroups.com) For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com (mailto:clojure%2bunsubscr...@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 (mailto:clojure@googlegroups.com) Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com (mailto: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 (mailto: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
Re: Clojure 1.5.1
fyi - Rich's .idea/ crept in on the bug fix commit. On Sunday, March 10, 2013 8:35:34 PM UTC+2, Stuart Halloway wrote: Clojure 1.5.1 fixes a memory leak in Clojure 1.5, discussed here: https://groups.google.com/d/msg/clojure-dev/uAFM0Ti4AcQ/GmnKmphF1BgJ Getting Clojure: Web: http://clojure.org/downloads Lein/Maven: :dependencies [[org.clojure/clojure 1.5.1]] Note that it will take a few hours for the links above to become live, as the completed build moves into Maven Central. Thanks, Stu Halloway Clojure/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 --- 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: Windows Installation
An alternative to GNU tools is to use the things that ship with Windows PowerShell and are on most developer's machines already, e.g. using the Invoke-RestMethod commandlet as an alternative to wget and curl. I have used PowerShell to simplify ClojureScript setup on Windows without too much trouble and I believe that it would be a simple solution for Clojure, too. Cheers, Martin -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Problem with Code Dispatch for Anonymous Functions?
After discussing with a couple of folks in IRC (big thank you to hyPiRion for his help), I opened a ticket to address this bug here: http://dev.clojure.org/jira/browse/CLJ-1181 Long story short, ((formatter-out ~#(~;~@{~w~^ ~_~}~;)~:) nlis) expects nlis to be a sequence, but in the case of (^:once fn* [x] x) it is a symbol. Thanks, -- '(Devin Walters) On Sunday, March 10, 2013 at 3:36 PM, Devin Walters wrote: Could anyone help me understand why the following code is breaking? (require '[clojure.pprint :refer [with-pprint-dispatch code-dispatch pprint]]) (with-pprint-dispatch code-dispatch (pprint (read-string (^:once fn* [x] x IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol clojure.lang.RT.seqFrom (RT.java:505) #( The #( is not a typo. It starts to print and then fails. Looking at the code, it looks like there's an issue here: (defn- pprint-anon-func [alis] (let [args (second alis) nlis (first (rest (rest alis)))] (if (vector? args) (binding [*symbol-map* (if (= 1 (count args)) {(first args) %} (into {} (map #(vector %1 (str \% %2)) args (range 1 (inc (count args))] ((formatter-out ~#(~;~@{~w~^ ~_~}~;)~:) nlis)) (pprint-simple-code-list alis I squinted at it for a bit, but I'm not sure what's up. Anyone have any ideas? Thanks, -- '(Devin Walters) -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: type inference in core.logic
Thank you! That's exactly what I was looking for. On Sunday, 10 March 2013 18:11:56 UTC-4, Ambrose Bonnaire-Sergeant wrote: Did you find the accompanying wiki? https://github.com/frenchy64/Logic-Starter/wiki Ambrose On Mon, Mar 11, 2013 at 4:37 AM, JvJ kfjwh...@gmail.com javascript:wrote: I feel as though I've seen a comprehensive tutorial involving type inference in core.logic. I've recently been looking through the links referred to in this posthttps://groups.google.com/forum/?fromgroups=#!searchin/clojure/core.logic$20type$20inference/clojure/Ioits6npTcs/OWNYNUQVTNgJ, however I'm finding them a little hard to follow. I feel as though I've seen another tutorial somewhere. If anyone has information on this, it would be appreciated. Thanks. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: 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+u...@googlegroups.com javascript:. 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.
fold over a sequence
As things currently stand, fold can be used on a sequence-based reducible collection, but won't be parallel. I'm currently working on code that processes XML generated by clojure.data.xml/parse, and would love to do so in parallel. I can't immediately see any reason why it wouldn't be possible to create a version of CollFold that takes a sequence and chunks it so that it can be folded in parallel. Has anyone tried this yet? Is there some gotcha lurking to catch me out? -- paul.butcher-msgCount++ Snetterton, Castle Combe, Cadwell Park... Who says I have a one track mind? http://www.paulbutcher.com/ LinkedIn: http://www.linkedin.com/in/paulbutcher MSN: p...@paulbutcher.com AIM: paulrabutcher Skype: paulrabutcher -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Newbie requesting review
Alright, thanks Gary and Marko, I really appreciate the advice! On Sunday, March 10, 2013 8:26:47 AM UTC-5, Marko Topolnik wrote: Several comments: 1. camelCase is not idiomatic for Clojure. Prefer lowercase-dashed-style. 2. use :keywords for map keys and, more generally, for any enumeration-type values (coming from a closed set of options). If you want JSON output, transform these into camelCased strings only at the checkout desk. Ugh, I *do* actually know better than that, thanks for pointing it out! 3. make-student-factory is what you'd call a *curried* function. You'd have an easier time with it if you declared it as a regular two-argument function and then used either clojure.core/partial or a literal #(make-student teacher-name %). That would allow you to use the function either directly as a student factory, or as a factory of student factories. Note that your approach to use a closure *is *idiomatic, I'm just advising a more idiomatic way to get it. Ok, I *think* I understand what you're saying. I did try an anonymous function at one point, but gave it up, I don't know why I did because it ended up working pretty well after reading your advice. How's this then? (ns teachers.core (:require [clj-json.core :as json])) (defn- gen-items-json [students] (json/generate-string {:timestamp 5000 :items students :identifier id :label id :rc 200 :msg Data retrieved successfully.})) (defn- make-student [teacher-name student-name age] {:id (str teacher-name ! student-name) :TeacherName teacher-name :StudentName student-name :age age}) (defn- make-name [prefix n] (str prefix n)) (defn- make-teacher-name [n] (make-name TEACHER n)) (defn- make-student-name [n] (make-name STUDENT n)) (defn- make-students [teacher-name n] (map #(make-student teacher-name (make-student-name %) 0) (range n))) (defn- spit-json [teacher-name n] (println Creating n students for teacher: teacher-name) (spit (str teacher-name .json) (gen-items-json (make-students teacher-name n (defn gen [num-teachers num-students] (doseq [teacher-name (map make-teacher-name (range num-teachers))] (spit-json teacher-name num-students))) Thanks a ton for your time, this list is really a great place and I appreciate being able to come here with questions! Cheers, Craig -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: fold over a sequence
On Mar 10, 2013, at 17:40, Paul Butcher wrote: As things currently stand, fold can be used on a sequence- based reducible collection, but won't be parallel. I'm currently working on code that processes XML generated by clojure.data.xml/parse, and would love to do so in parallel. I can't immediately see any reason why it wouldn't be possible to create a version of CollFold that takes a sequence and chunks it so that it can be folded in parallel. Has anyone tried this yet? Is there some gotcha lurking to catch me out? I love the idea; dunno if there are any gremlins lurking. BTW, if you haven't already done so, be sure to watch Guy Steele's talk: How to Think about Parallel Programming: Not! http://www.infoq.com/presentations/Thinking-Parallel-Programming The first third of the talk (~20 minutes) is a wonderful discussion of extreme hacking (eg, a single-card dump program for an IBM 1130). Guy then segues into a discussion of giving up control of details in order to let the system take care of things (eg, memory use). The last part of the talk is about the conceptual basis for order- independent folding of calculations. So, required viewing (IMHO) if you're thinking about extending reducers, etc. -r -- http://www.cfcl.com/rdmRich Morin http://www.cfcl.com/rdm/resume r...@cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841 Software system design, development, and documentation -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Clojure 1.5.1
I think there's a typo in the download link on http://clojure.org/downloads: It says http://repo1.maven.org/maven2/org/clojure/clojure/1.5.*0* /clojure-1.5.1.ziphttp://repo1.maven.org/maven2/org/clojure/clojure/1.5.0/clojure-1.5.1.zip whereas it should be http://repo1.maven.org/maven2/org/clojure/clojure/1.5.* 1*/clojure-1.5.1.ziphttp://repo1.maven.org/maven2/org/clojure/clojure/1.5.1/clojure-1.5.1.zip (note the 1.5.1 vs. 1.5.0 in the second to last part of the URL) Am Sonntag, 10. März 2013 19:35:34 UTC+1 schrieb stuart@gmail.com: Clojure 1.5.1 fixes a memory leak in Clojure 1.5, discussed here: https://groups.google.com/d/msg/clojure-dev/uAFM0Ti4AcQ/GmnKmphF1BgJ Getting Clojure: Web: http://clojure.org/downloads Lein/Maven: :dependencies [[org.clojure/clojure 1.5.1]] Note that it will take a few hours for the links above to become live, as the completed build moves into Maven Central. Thanks, Stu Halloway Clojure/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 --- 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.
Querying hierarchies in core.logic
I understand that it is possible, and I have found a code example here : https://github.com/frenchy64/Logic-Starter/blob/master/src/logic_introduction/extend.clj#L76 However, the code presented is rather terse, and some functions, such as lvar-in? aren't documented. Does anyone know of something that describes this code, or at least the process involved? 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.
Re: ANN: Iota 1.0.2 release (Reducers for text files)
Hi Bernard, I'm going to see if I can add some performance metrics in the test code to try and determine where various bottlenecks may exist. If that goes well I'll see if I can add a branch that returns Byte[] instead of String for iota/vec. I suspect this will just require modifying iota.FileVector.getChunk() and iota.FileVector.cachedChunk . I'm still not clear on a good way to handle ByteBuffer with offsets though, because Java's mmap() doesn't support reading from files greater that Integer/MAX_VALUE. To work around this I've had to patch the following together; https://github.com/thebusby/iota/blob/master/src/java/iota/Mmap.java I do think I understand what you're asking for though. Unfortunately for this level of tuning I still primarily fall back to C and JNI, so my Java/Clojure is likely a little weak here. Regarding why iota/vec returns nil on empty lines, it's to allow for (- (iota/vec filename.tsv) (r/filter identity) ... Hope this helps, Alan On Sat, Mar 9, 2013 at 9:41 AM, bernardH un.compte.pour.tes...@gmail.comwrote: Hi Alan, On Friday, March 8, 2013 4:02:18 PM UTC+1, Alan Busby wrote: Hi Bernard, I'd certainly like to add support for binary files, but as I haven't had a need for it myself I haven't had a good place to start. As Java NIO's mmap() doesn't support ranges over 2GB, I've had to paste together multiple mmap's to cover files that are larger than 2GB. So if a record ended up spanning two mmap()'s, you couldn't return the raw data as a single object without copying it into a new buffer first. Also, if you provide a fixed record size in bytes for doing the idx offset maths, why do you need the end idx for the current line as well? For example if you say file.bin is full of records each 100B in size, and you ask for the 10th record; don't you already know that the length of the record is 100B? Indeed, the correlation between txt/binary and char (i.e \n) delimited/fixed length record is very strong. However in my case I want to first handle a \n delimited (txt) file as binary for performance reasons. The context is that I have to consider all the lines of data, but might not have to do heavy processing on all of them, so I want to do as few work as possible on each line (i.e. not construct any java.lang.String). This is in no way Clojure specific, I have two implementations in Java of a small Minimum Spanning Tree program : - one is constructing Strings from all the lines: https://www.refheap.com/paste/12312 - one is using offsets from a raw ByteBuffer : https://www.refheap.com/paste/12313 As most of the lines are not really processed (just sorted according to the last field), being able to only peek at the relevant bytes instead of constructing full blown java.lang.Strings is a huge performance boost. FWIW, as far as performance i concerned, I draw the line not between Clojure and Java but between objects (constructed by copying some data somewhere on the heap) and arrays of primitive data types, because nowadays, cache locality trumps everything (once you got rid of reflection calls in Clojure, obviously). So ideally, maybe 2 x 2 combinations (String / offset in ByteArray) x (char delimited / fixed length) would be needed to cover all the needs. Thanks again for sharing your library ! Cheers, Bernard PS: Is there a rationale for returning nil instead of empty String on empty lines with iota/vec? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: fold over a sequence
On Mon, Mar 11, 2013 at 9:40 AM, Paul Butcher p...@paulbutcher.com wrote: I'm currently working on code that processes XML generated by clojure.data.xml/parse, and would love to do so in parallel. I can't immediately see any reason why it wouldn't be possible to create a version of CollFold that takes a sequence and chunks it so that it can be folded in parallel. Has anyone tried this yet? Is there some gotcha lurking to catch me out? I've done something like the above here; https://github.com/thebusby/iota/blob/master/src/clj/iota.clj I haven't run in to any gotcha's yet after 6+ months of extensive use. I did have to copy/paste the definitions for pool, fjtask, fjinvoke, fjfork, fjjoin from core/reducers.clj and keep them from being AOT compiled (for Java 1.7 and 1.6 compatibility). I'm not pleased with the way the thread pool is inaccessible in core/reducers.clj because I'm not aware of any mechanism to have fold *NOT* use every available resource. Hope this helps, Alan -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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.