Re: ANN lein-daemon, lein-test-out
Re Just fyi - when running clojure program under daemon on windows, you can get NPE, if you'll try to load file or resources. See http://www.assembla.com/spaces/clojure/tickets/379 for details Allen Rohner at "Thu, 15 Jul 2010 15:00:03 -0700 (PDT)" wrote: AR> I'd like to announce two new lein plugins, lein daemon and lein test- AR> out. AR> Lein-daemon is a wrapper around the Apache Commons Daemon, for AR> starting a clojure process as a daemon. AR> Lein test-out is a plugin for running your tests and outputting the AR> results to junit or TAP (using clojure.test.junit and AR> clojure.test.tap). AR> You can find them at http://github.com/arohner/lein-daemon , and AR> http://github.com/arohner/lein-test-out , and clojars. AR> Allen -- With best wishes, Alex Ott, MBA http://alexott.blogspot.com/ http://alexott.net http://alexott-ru.blogspot.com/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: terracotta?
To repeat myself again: The big problem with a MVCC based STM, is that there is a central clock that needs to be touched by independent transactions. That was one of the reasons for me to get not started on a distributed STM. So you will get something up and running on your laptop, but it will not be of great value in a scalable system (since it limits scalability). The best way forward imho is to remove the central clock either by: - a vector clock (most expensive read validations instead of a simple long comparison, more complex infrastructure since you don't want to have ever growing timestamps in your system). - use a different (d)stm mechanism. The cool thing about mvcc/tl2 is that you can go back to previous history.. with other stm mechanisms this might be more tricky. Or you could try to enter the nosql domain, so dealing with various levels of consistency and perhaps broken failure atomicity (since some of them only guarantee atomicity over a single 'record' and not over records spanning multiple machines that are modified in a single transaction. On Jul 16, 4:51 am, Alex Miller wrote: > Hi, > > I used to be a tech lead at Terracotta but I am now a full-time > Clojure dev. I think it would be very interesting to explore the new > Terracotta Toolkit product to provide a distributed store for Clojure > data structures. I think it actually comes out in GA next week > although it's been available to try for a while. If only I had 47 > hours per day I would be all over giving it a try. If someone is > banging on it and needs help, I'm happy to connect you to the right > people or give you some pointers. > > Also, Sergio is doing some awesome work with Terrastore and I'd highly > recommend giving it a shot if it fits your needs! > > I'd really like to hear some detailed use cases for what you want out > of Clojure/Terracotta integration. Is it shared Clojure data? Locking? > Coordination? Caching? Remote code execution? > > Alex > > On Jul 15, 7:51 pm, Paul Stadig wrote: > > > If anyone is interested, the latest version of my terracotta TIM is > > athttp://github.com/pjstadig/tim-clojure-1.0.0andit tries to be a Clojure > > 1.0.0 compatible TIM, which shows how its a bit out-of-date. > > > I am very open to collaboration, and I would love pull requests, or any > > patches that anyone sends. > > > Paul > > http://paul.stadig.name/(blog) > > 703-634-9339 (mobile) > > pjstadig (twitter) > > p...@stadig.name (jabber) > > > On Thu, Jul 15, 2010 at 12:35 PM, scx wrote: > > > Hi -- > > > > I'm noob to both Clojure and Terracotta but if you're willing to > > > tolerate basic questions from me, I'd be very interested in helping > > > out. > > > > On Jul 12, 3:36 am, peter veentjer wrote: > > > > I don't think it every is going to scale. > > > > > MVCC/TL2 based STM designs rely on a central clock, so if you can > > > > update the clock in 0.1 ms on all machines, the maximum throughput is > > > > 1/0.0001 = 10.000 transactions/second... no matter how many machines > > > > you throw at it. Even on a single machine the central clock can cause > > > > scalability problems (10/20M transactions/second and this will degrade > > > > when you throw more cores at it). > > > > > This is one of the reasons I dropped the TL2 approach for Multiverse > > > > and switched over to the SkySTM model (with some magic of my own) that > > > > doesn't relied as much on a central mechanism. > > > > > On Jul 11, 6:50 pm, scx wrote: > > > > > > hi -- > > > > > > i've seen paul standig's work with clojure +terracotta. wondering if > > > > > anyone has continued his work? > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Clojure" group. > > > To post to this group, send email to clojure@googlegroups.com > > > Note that posts from new members are moderated - please be patient with > > > your first post. > > > To unsubscribe from this group, send email to > > > clojure+unsubscr...@googlegroups.com > > > > > > For more options, visit this group at > > >http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Cljr and user.clj
I've just installed Cljr and am really impressed with it... However I have run into a small problem. I'd like to have my cljr execute my user.clj at startup, however it seems that cljr is ignoring classpaths added with the command cljr add-classpath ~/.clojure/ looking in ~/.cljr/project.clj I see that this has been added correctly, and that if I execute lein swank in the .cljr directory, lein correctly picks up the user.clj file on my classpath... indicating that there is a problem with cljr. Otherwise cljr is great... Any help appreciated. R. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Building mixed clojure and java code
Thanks, that got me up and running! I had to upgrade to head lein and wipe my maven repository first (as per http://groups.google.com/group/leiningen/browse_thread/thread/8f2ef7edb9fda3be?pli=1) and then pull the latest lein-javac, and after that it all worked smoothly. martin On Thu, Jul 15, 2010 at 12:41 AM, Mark McGranaghan wrote: > Hi Martin, > > http://github.com/mmcgrana/clj-json is a simple example of a Clojure > +Java library that you could use as a working example. See in > particular project.clj the Development section of README.md. > > Hope this helps, > - Mark > > On Jul 14, 6:16 am, Martin DeMello wrote: >> On Wed, Jul 14, 2010 at 6:45 PM, Martin DeMello >> wrote: >> > What are people using to build mixed clojure/java code? Currently just >> > using lein {uber,}jar to build and distribute. >> >> Hit send too soon - I meant to say, currently my project is just >> clojure, and lein works very nicely to package it. If I wanted to >> include some java sources, what would the easiest way to build the >> combined project be? >> >> 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: defmulti - defonce semantics?
On Jul 14, 4:09 pm, Michał Marczyk wrote: > If you're ok with discarding all your methods for the given multi, you can do > > (ns-unmap the-ns-of-defmultiname-of-the-multimethod) > > (I'm not sure if you should also unmap it in namespaces which refer to > that Var just now...) > > Then the entire multifunction will be recreated when you recompile. Hi, perhaps someone has already stumble upon this issue: For some reason, when using immigrate, defmethod is not working. that is, defmethod inside a namespace which 'use a namespace which 'immigrate a defmulti does not seem to a dispatch function to the (methods 'multimethod). Does it make sense? regards, Pedro -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure noob: refactoring factorial code
Thanks for the response. To get an idea of what I mean, visit http://www.wolframalpha.com/''. Then enter something ridiculous (to me, at least) like 10! The answer is almost instantaneous. The question is: how would someone write idiomatic Clojure in such a way that it gives exact results for n, and reasonable approximations (BigDecimal?) for large values of n, without having to write a separate function? In imperative/procedural languages, based available computing resources one would arrive at some arbitrary value (say, 1000) and use different algorithms based on the size of n. Is this also the case for Clojure? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Command line debugging
Sorry if this has already been answered, but what's the best recipe for getting a command line debugger going with clojure 1.2 snapshots? I've read about debug-repl and other solutions but I'm not sure what works with 1.2. Thanks, Steve -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure noob: refactoring factorial code
Hello Mike, Thanks for taking time to respond. I replied to another post but somehow it didn't show up. Perhaps it is awaiting moderation. Anyway, perhaps I should explain the situation more clearly. In conventional imperative/procedural languages, as you pointed out, the algorithm used to calculate the factorial would be dependent on available compute resources. In order to select the appropriate algorithm one might select an arbitrary value (let's say 1000) and decide to use one algorithm or another. Or we might use a totally different function altogether. Is this also the case with Clojure? Being a newbie I have not fully understood how one would tackle such a problem. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Saving runtime clojure image
Hi, I've read in some old discussion ( http://groups.google.com/group/clojure/browse_thread/thread/5259280f2fd8c8a5/ ) that "Clojure cannot save a runtime image the way SBCL and other Lisps can." Is this still true or is it possible to save-lisp-and-die? If not, are there plans for such functionality or it is inherently impossible to do such thing in clojure? With such functionality, I could do some REPL hacking, save the runtime state and later get back to it. Best, Jozef -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
extend-protocol bug?
I have record J:Bot, protocol P:Bot and two files, one extend-protocol statement by file. After loading first file i get: http://pastebin.com/Kq5GZ6RJ After loading second file i get: http://pastebin.com/Pu3kHZ1h Looks like next extend-protocol rewrite :impls seg. How/where post the bug? Or myabe this is a feature? :] -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Saving runtime clojure image
Not provided by the underlying platform, the JVM. But one could consider recording your interactions with the REPL, and having an option to replay them at startup. With time, your REPL will start slower and slower and slower though. And even with an "history replay" feature, there will be times when the replay is not sufficient (since you cannot totally control the I/O environment: date/time, file/network resources, etc.) 2010/7/16 Jozef Wagner > Hi, > > I've read in some old discussion ( > > http://groups.google.com/group/clojure/browse_thread/thread/5259280f2fd8c8a5/ > ) that > "Clojure cannot save a runtime image the way SBCL and other Lisps > can." > > Is this still true or is it possible to save-lisp-and-die? If not, are > there plans for such functionality or it is inherently impossible to > do such thing in clojure? > > With such functionality, I could do some REPL hacking, save the > runtime state and later get back to it. > > Best, > Jozef > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure noob: refactoring factorial code
On 15 July 2010 16:24, Brisance wrote: > Thanks for the response. > > To get an idea of what I mean, visit http://www.wolframalpha.com/''. > Then enter something ridiculous (to me, at least) like 10! > > The answer is almost instantaneous. Wolfram Alpha is merely approximating the result to a certain precision. I highly doubt it's actually calculating the whole number and then just stripping off the first N digits! - 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
Re: Clojure 1.2 Beta 1
Hi, I think I found a minor problem. It appears with the error handling of agents and actually is just a minor glitch in the output. Consider the following session, copied from a terminal: shell> java -cp clojure.jar clojure.main Clojure 1.2.0-beta1 user=> (def agt1 (agent "One")) #'user/agt1 user=> (defn upd-agt1 [current new-val] (if (= new-val "fail") (throw (Exception. "Update failed.")) (str "Update: " new-val))) #'user/upd-agt1 user=> (error-mode agt1) :fail user=> (send agt1 upd-agt1 "fail") # It creates an agent and causes an error in the update function. The error mode of the agent is :fail and it silently fails when calling the action. The failed status is visible from the printed output of the agent in the last line. Further attempts to update the agent will raise an exception. Now for a second version see the following session, which started fresh. It does the same thing as the first session, but it makes sure that the thread-pool for the agents contains more threads, first. shell> java -cp clojure.jar clojure.main Clojure 1.2.0-beta1 ;; this just creates some threads in the pool user=> (def agt2 (agent {:count 0})) #'user/agt2 user=> (defn agt2-action [state] (println "In Thread" (.getName (Thread/currentThread))) (if (< (:count state) 5) (do (send agt2 agt2-action) (assoc state :count (inc (:count state state)) #'user/agt2-action user=> (send agt2 agt2-action) In Thread pool-1-thread-1 # In Thread pool-1-thread-4 user=> In Thread pool-1-thread-4 ;; now the same as before... user=> (def agt1 (agent "One")) #'user/agt1 user=> (defn upd-agt1 [current new-val] (if (= new-val "fail") (throw (Exception. "Update failed.")) (str "Update: " new-val))) #'user/upd-agt1 user=> (error-mode agt1) :fail user=> (send agt1 upd-agt1 "fail") # This time the output doesn't show the FAILED status of the agent. I am by no means sure that this change in behavior is related to the pool of threads. I found it by accident and could reproduce it several times. Kind regards, Stefan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure noob: refactoring factorial code
> > In conventional imperative/procedural languages, as you pointed out, > the algorithm used to calculate the factorial would be dependent on > available compute resources. In order to select the appropriate > algorithm one might select an arbitrary value (let's say 1000) and > decide to use one algorithm or another. Or we might use a totally > different function altogether. > > Is this also the case with Clojure? Being a newbie I have not fully > understood how one would tackle such a problem. You can use the traditional, precise algorithm when n is tractable, and use Stirling's formula to approximate for large n: n! ~ sqrt(2*pi*n)*(n/e)^n This approach seems reasonable to me, assuming you really need to handle the large values. -Brendan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: extend-protocol bug?
It's better to illustrate this with simple example: If I'll define following protocol: (defprotocol test1 (a1 [this] "a1") (a2 [this] "a2") (a3 [this] "a3") ) and then I can extend it with following constuction: (extend-protocol test1 String (a1 [this] (str "Hello1 " this "!"))) then I get no warning, that protocol test1 has 3 methods, and if I'll try to call corresponding, not defined methods, then I'll get (a2 "bbb") --> method not defined and if I'll try to extend it further with following call (extend-protocol test1 String (a2 [this] (str "Hello1 " this "!"))) then a2 will defined, but a1 become undefined. May be we'll need either have a warning, that extend-protocol doesn't defines all necessary methods, or we'll need to allow to "append" methods, not defined earlier [AvataR] at "Fri, 16 Jul 2010 16:27:36 +0300" wrote: [> I have record J:Bot, protocol P:Bot [> and two files, one extend-protocol statement by file. [> After loading first file i get: [> http://pastebin.com/Kq5GZ6RJ [> After loading second file i get: [> http://pastebin.com/Pu3kHZ1h [> Looks like next extend-protocol rewrite :impls seg. How/where post the [> bug? [> Or myabe this is a feature? :] -- With best wishes, Alex Ott, MBA http://alexott.blogspot.com/http://alexott.net/ http://alexott-ru.blogspot.com/ Skype: alex.ott -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ClojureDocs.org
Hi. Does clojuredocs expose any external API (json, xml... rest, webservices, etc) so I can access the docs from my code? Islon On Jul 13, 11:40 pm, j-g-faustus wrote: > On Jul 13, 8:37 pm, Paul Moore wrote: > > > Can I suggest omitting the "Table of contents" sidebar when printing? > > I've not tried printing the document to see how it looks, but removing > > the sidebar would be an essential starting point... > > Why would anyone want to print it? > > I occasionally print longer texts like specifications, but for > reference material like Javadoc,ClojureDocs, the Ruby cheat sheet and > this page, I think HTML is a far superior format due to links and > browser search. > And 40+ loose single sheets is a rather cumbersome package unless you > have access to a book binder. > > But if at least two people feel that they would really like to print > it out, I can skip the TOC on print. > > (Making it look _nice_ on paper is a whole different ballgame, then > I'd have to look into pagination and page layouts, perhaps by > converting to DocBook or LaTex. That's outside the scope of what I > intended to do.) > > On Jul 13, 10:04 pm, Meikel Brandmeyer wrote: > > > Some comments after quickly skimming through: > > ... > > PS: I'm apologise if some this seems to be nit-picking. > > Not at all, I'm still learning the language and happy to get the > details clarified. > > The second form of condp and the #_ were omitted simply because I > didn't know about them, thanks for the heads-up. > > For quoted lists, I take your point. > For the sequence operations examples it was somewhat deliberate, in > that a sequence is a very different datatype from a vector but pretty > much the same as a list. > I had a bug in some code that conj'ed elements onto a vector, but for > some reason it would switch direction in the middle and start adding > elements at the opposite end. It took me a while to figure out that it > was because concat'ing two vectors doesn't return a vector. > So I wanted to emphasize that using a sequence op on anything other > than a list is also a conversion from one datatype to another. > But I'll take another look, there may be better ways. > > Thanks for your comments, much appreciated. I'll include them with the > next update. > > Sincerely, > jf -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Clojure Job Opening in Ghent Belgium
Hi all, I hope you don't mind me sharing Clojure job opportunity in Ghent Belgium. Our university library is searching for a developer willing to participate in an open source project to create an image database to present high resolutions scans of old manuscripts on the Internet. Here is the (Dutch) posting: http://www.ugent.be/nl/nieuwsagenda/vacatures/atp/contract-tijdelijk/ivh Working on site in Ghent for 13 months. Best, Patrick -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ClojureDocs.org
Had another suggestion, As an example contributor, It would be really nice to see a list of functions that have no examples yet at a glance, so if I wanted to work on adding examples I could go through a list and work on functions that have no examples. I believe the clojure-examples appspot wiki used to dim out functions that didn't have any examples (I don't think it does this any more), which was very helpful. If we did this, we could even have a percentage meter to work toward 100% API example coverage :) - Lee -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: extend-protocol bug?
This behavior is by design. (1) The absence of warning is consistent with proxy, reify, etc. You specify as much as you want, and there is no warning. This is very unlikely to change! (2) The dynamism implied by a hypothetical "append-partial-protocol" seems high on complexity and low on value. But since it came up, maybe I'm wrong. Real motivating examples always welcome. Stu > It's better to illustrate this with simple example: > > If I'll define following protocol: > > (defprotocol test1 > (a1 [this] "a1") > (a2 [this] "a2") > (a3 [this] "a3") > ) > > and then I can extend it with following constuction: > > (extend-protocol test1 String > (a1 [this] (str "Hello1 " this "!"))) > > then I get no warning, that protocol test1 has 3 methods, and if I'll try > to call corresponding, not defined methods, then I'll get > > (a2 "bbb") --> method not defined > > and if I'll try to extend it further with following call > > (extend-protocol test1 String > (a2 [this] (str "Hello1 " this "!"))) > > then a2 will defined, but a1 become undefined. > > May be we'll need either have a warning, that extend-protocol doesn't > defines all necessary methods, or we'll need to allow to "append" methods, > not defined earlier > > > [AvataR] at "Fri, 16 Jul 2010 16:27:36 +0300" wrote: > [> I have record J:Bot, protocol P:Bot > [> and two files, one extend-protocol statement by file. > [> After loading first file i get: > [> http://pastebin.com/Kq5GZ6RJ > [> After loading second file i get: > [> http://pastebin.com/Pu3kHZ1h > > [> Looks like next extend-protocol rewrite :impls seg. How/where post the > [> bug? > > [> Or myabe this is a feature? :] > > > > -- > With best wishes, Alex Ott, MBA > http://alexott.blogspot.com/http://alexott.net/ > http://alexott-ru.blogspot.com/ > Skype: alex.ott > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Beta 1
Hi Stefan, The behavior you are seeing is not a problem, and understanding why may be helpful to using agents correctly. The thread that sends to an agent has no guarantee that it will (or will not) see the result of its action a tiny bit later, when the repl prints the stringified version of the agent. If you want to guarantee that your thread sees the results of its own sends, you can call await. To be sure you were seeing a bug, you would need to (1) create an agent (2) have no other threads sending to the agent (3) send something that caused an error (4) await Your example is missing step 4. When I tried it with step 4 included, the behavior was reliable. Of course that doesn't prove that there isn't a bug... :-) Stu > Hi, > > I think I found a minor problem. It appears with the error handling > of agents and actually is just a minor glitch in the output. > > Consider the following session, copied from a terminal: > > shell> java -cp clojure.jar clojure.main > Clojure 1.2.0-beta1 > user=> (def agt1 (agent "One")) > #'user/agt1 > user=> (defn upd-agt1 [current new-val] > (if (= new-val "fail") > (throw (Exception. "Update failed.")) > (str "Update: " new-val))) > #'user/upd-agt1 > user=> (error-mode agt1) > :fail > user=> (send agt1 upd-agt1 "fail") > # > > It creates an agent and causes an error in the update function. The > error mode of the agent is :fail and it silently fails when calling > the action. The failed status is visible from the printed output of > the agent in the last line. Further attempts to update the agent will > raise an exception. > > Now for a second version see the following session, which started > fresh. It does the same thing as the first session, but it makes sure > that the thread-pool for the agents contains more threads, first. > > shell> java -cp clojure.jar clojure.main > Clojure 1.2.0-beta1 > ;; this just creates some threads in the pool > user=> (def agt2 (agent {:count 0})) > #'user/agt2 > user=> (defn agt2-action [state] > (println "In Thread" (.getName (Thread/currentThread))) > (if (< (:count state) 5) > (do (send agt2 agt2-action) > (assoc state :count (inc (:count state > state)) > #'user/agt2-action > user=> (send agt2 agt2-action) > In Thread pool-1-thread-1 > # In Thread pool-1-thread-3 > {:countIn Thread pool-1-thread-4 > 1}> > In Thread pool-1-thread-4 > user=> In Thread pool-1-thread-4 > ;; now the same as before... > user=> (def agt1 (agent "One")) > #'user/agt1 > user=> (defn upd-agt1 [current new-val] > (if (= new-val "fail") > (throw (Exception. "Update failed.")) > (str "Update: " new-val))) > #'user/upd-agt1 > user=> (error-mode agt1) > :fail > user=> (send agt1 upd-agt1 "fail") > # > > > This time the output doesn't show the FAILED status of the agent. > > I am by no means sure that this change in behavior is related to the > pool of threads. I found it by accident and could reproduce it > several times. > > Kind regards, > Stefan > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Beta 1
Going to http:// clojure.org, searching for git and following the "Clojure goes git" link would lead one to http://groups.google.com/group/clojure/msg/ca4fb58428052554 which suggests that the rickhickey page is the right one. Where's the announcement about git://github.com/clojure ? thanks, cyrus On Jul 15, 2010, at 10:02 AM, Jeffrey Schwab wrote: > On 7/15/10 10:15 AM, Adrian Cuthbertson wrote: >> Apparently there's a problem with git clone http://... >> >> Should be git clone git://github.com/clojure/clojure.git >> >> Sorry for the noise. > > Thanks, I've been mistakenly working from > > git://github.com/richhickey/clojure.git > > > ...which is apparently why I didn't see any commits since June. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Implementing a protocol with using a base implementation?
Hi all, I am writing a network protocol handler based on events (to wrap netty, if you're curious). I created a protocol that defines the functions needed to handle every possible (channel) event: (defprotocol channel-handler-strategy (message-received [this ctx evt]) (exception-caught [this ctx evt]) ... ) And I also provide a default event handler that will call the appropriate handler function of the channel-handler-strategy protocol depending on the type of event and some other data, for example: (defrecord simple-channel-handler [strategy] channel-handler (handle-upstream [this ctx evt] (if (= ctx "hello") (message-received strategy ctx evt) (exception-caught strategy ctx evt Note: this is toy code, the real code hasn't been written yet ;) Here is the problem I am trying to solve: the list of handler functions that the protocol will define is lng, and for most of the cases, the developer will only want to perform some custom logic in one or two of the handler functions, expecting that the rest of the handler functions will perform some sort of default action (forward the event in this case). If my understanding of the new type system in 1.2 is correct, there is no way create a record by extending another record, nor a way to override functions of a record. Thus, with the current tools, every channel-handler-strategy implementor would have to provide a definition for *all* the functions defined in the protocol. I thought of some solutions, but I get the feeling I might just be approaching the problem from the wrong angle. 1) The channel-handler-stategy implementor only implements the handler functions he/she cares about, leaving the rest unimplemented. When the event handler calls one of the unimplemented handler functions and exception will be thrown, and so the event handler can catch them and execute the default behavior. 2) If there was a way to build a record from a map e.g: {fn-name fn- definition}, then I'd be able to create a default handler function map which the channel-handler-strategy implementors would merge with their own custom maps that contained only the redefined handler functions, and then use this merged map to create the record. I could not find any existing way to do this but I believe it should be possible to write a macro to do create a record from such map. 3) Use structs, but that would be too slow for my use case. So here is the question: Am I approaching this problem the wrong way? Or this use case for types is an only edge case and I should go ahead and build a custom solution based on any of the above proposed solutions? Thanks in advance for your thoughts, Toni. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Beta 1
Hi Stu, On 16 Jul., 19:54, Stuart Halloway wrote: > Hi Stefan, > > The behavior you are seeing is not a problem, and understanding why may be > helpful to using agents correctly. > > The thread that sends to an agent has no guarantee that it will (or will not) > see the result of its action a tiny bit later, when the repl prints the > stringified version of the agent. yeah, after posting this I went over to core_print.clj and took a look. I was also thinking about proposing that the REPL should await (or better await-for), but since the REPL can't know when the agent will finish, it wouldn't be good either. I can't think of a reliable solution for this. The same thing happens (of course) with the output of the current value, not just the error-state. I think the fact that having a thread-pool or not made a difference got me on the wrong track in the first place. Best regards, Stefan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Beta 1
On 7/16/10 2:42 PM, Cyrus Harmon wrote: Going to http:// clojure.org, searching for git and following the "Clojure goes git" link would lead one to http://groups.google.com/group/clojure/msg/ca4fb58428052554 which suggests that the rickhickey page is the right one. Where's the announcement about git://github.com/clojure ? http://clojure.org/downloads "Clojure source code is hosted at github.com/clojure/clojure." I don't know whether there was any formal announcement. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: extend-protocol bug?
May be at least this should be documented? I could understand, that some developers will be mixed up by behavior... On Friday, July 16, 2010, Stuart Halloway wrote: > This behavior is by design. > > (1) The absence of warning is consistent with proxy, reify, etc. You specify > as much as you want, and there is no warning. This is very unlikely to change! > > (2) The dynamism implied by a hypothetical "append-partial-protocol" seems > high on complexity and low on value. But since it came up, maybe I'm wrong. > Real motivating examples always welcome. > > Stu > >> It's better to illustrate this with simple example: >> >> If I'll define following protocol: >> >> (defprotocol test1 >> (a1 [this] "a1") >> (a2 [this] "a2") >> (a3 [this] "a3") >> ) >> >> and then I can extend it with following constuction: >> >> (extend-protocol test1 String >> (a1 [this] (str "Hello1 " this "!"))) >> >> then I get no warning, that protocol test1 has 3 methods, and if I'll try >> to call corresponding, not defined methods, then I'll get >> >> (a2 "bbb") --> method not defined >> >> and if I'll try to extend it further with following call >> >> (extend-protocol test1 String >> (a2 [this] (str "Hello1 " this "!"))) >> >> then a2 will defined, but a1 become undefined. >> >> May be we'll need either have a warning, that extend-protocol doesn't >> defines all necessary methods, or we'll need to allow to "append" methods, >> not defined earlier >> >> >> [AvataR] at "Fri, 16 Jul 2010 16:27:36 +0300" wrote: >> [> I have record J:Bot, protocol P:Bot >> [> and two files, one extend-protocol statement by file. >> [> After loading first file i get: >> [> http://pastebin.com/Kq5GZ6RJ >> [> After loading second file i get: >> [> http://pastebin.com/Pu3kHZ1h >> >> [> Looks like next extend-protocol rewrite :impls seg. How/where post the >> [> bug? >> >> [> Or myabe this is a feature? :] >> >> >> >> -- >> With best wishes, Alex Ott, MBA >> http://alexott.blogspot.com/ http://alexott.net/ >> http://alexott-ru.blogspot.com/ >> Skype: alex.ott >> > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- With best wishes,Alex Ott, MBA http://alexott.net/ Tiwtter: alexott_en (English), alexott (Russian) Skype: alex.ott -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Beta 1
Hi, FWIW... I've delayed this work for ages, but now that 1.2 is just around the corner I have no reason to wait any longer. So I went through all [1] examples from our forthcoming book [2] and tested them with the current beta. The result of this is encouraging: everything works fine. Until now I skipped most of the contrib library and the parts where we show how to use Clojure stuff from Java. Need something to do for the weekend ;). The only issues I had so far where when I tried to include contrib.repl-utils and ns-utils which clash with other names in the user-namespace and thus can't be safely included. You can work around this by :only importing what you need, though. Kudos! Hope this helps, Stefan [1] I looked at more than 400 verbatim environments in the LaTeX- sources, containing almost 900 user>-prompts and approximately 300 (defn\?-initions. Mostly simple examples, but two larger programs, too, which comprise one or two screen-pages of functions and give the CPUs something to work on. [2] http://www.clojure-buch.de (warning: self-ad, even more warning: German content) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Implementing a protocol with using a base implementation?
Not very clean suggestion. Split the protocol in one protocol per function. Instance every one on Object, with the default protocol. Instance each specific on the function for which it has a special instance. On Fri, Jul 16, 2010 at 7:45 PM, tbatchelli wrote: > Hi all, > > I am writing a network protocol handler based on events (to wrap > netty, if you're curious). I created a protocol that defines the > functions needed to handle every possible (channel) event: > > (defprotocol channel-handler-strategy > (message-received [this ctx evt]) > (exception-caught [this ctx evt]) > ... > ) > > And I also provide a default event handler that will call the > appropriate handler function of the channel-handler-strategy protocol > depending on the type of event and some other data, for example: > > (defrecord simple-channel-handler [strategy] > channel-handler > (handle-upstream [this ctx evt] > (if (= ctx "hello") > (message-received strategy ctx evt) > (exception-caught strategy ctx evt > > Note: this is toy code, the real code hasn't been written yet ;) > > Here is the problem I am trying to solve: the list of handler > functions that the protocol will define is lng, and for most of > the cases, the developer will only want to perform some custom logic > in one or two of the handler functions, expecting that the rest of the > handler functions will perform some sort of default action (forward > the event in this case). If my understanding of the new type system in > 1.2 is correct, there is no way create a record by extending another > record, nor a way to override functions of a record. Thus, with the > current tools, every channel-handler-strategy implementor would have > to provide a definition for *all* the functions defined in the > protocol. > > I thought of some solutions, but I get the feeling I might just be > approaching the problem from the wrong angle. > > 1) The channel-handler-stategy implementor only implements the handler > functions he/she cares about, leaving the rest unimplemented. When the > event handler calls one of the unimplemented handler functions and > exception will be thrown, and so the event handler can catch them and > execute the default behavior. > > 2) If there was a way to build a record from a map e.g: {fn-name fn- > definition}, then I'd be able to create a default handler function map > which the channel-handler-strategy implementors would merge with their > own custom maps that contained only the redefined handler functions, > and then use this merged map to create the record. I could not find > any existing way to do this but I believe it should be possible to > write a macro to do create a record from such map. > > 3) Use structs, but that would be too slow for my use case. > > So here is the question: Am I approaching this problem the wrong way? > Or this use case for types is an only edge case and I should go ahead > and build a custom solution based on any of the above proposed > solutions? > > Thanks in advance for your thoughts, > > Toni. > > > > > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Implementing a protocol with using a base implementation?
I read my mail and couldn't understand it. Here is what I meant: (defprotocol MessageReceived (message-received ...)) (defprotocol ExceptionCaught .) (extend Object MessageReceved {:message-received default-message-received-function}... ) (deftype channel-handler ExceptionCaught ) (not the lack of message received implementation) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Cljr and user.clj
Rick, I think the problem is that additional classpaths are added, dynamically, after the user.clj file is evaluated. It does get evaluated if it's in ./ or ./src, which are added at launch in the cljr scripts. I have added ~/.cljr to the classpath defined in the launch scripts, so you can place your user.clj there. Thanks for catching that, I like to use user.clj too :-) David On Jul 16, 8:44 am, Rick Moynihan wrote: > I've just installed Cljr and am really impressed with it... However I > have run into a small problem. > > I'd like to have my cljr execute my user.clj at startup, however it > seems that cljr is ignoring classpaths added with the command > > cljr add-classpath ~/.clojure/ > > looking in ~/.cljr/project.clj I see that this has been added > correctly, and that if I execute lein swank in the .cljr directory, > lein correctly picks up the user.clj file on my classpath... > indicating that there is a problem with cljr. > > Otherwise cljr is great... Any help appreciated. > > R. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure noob: refactoring factorial code
"James Reeves" wrote: >On 15 July 2010 16:24, Brisance wrote: >> Thanks for the response. >> >> To get an idea of what I mean, visit http://www.wolframalpha.com/''. >> Then enter something ridiculous (to me, at least) like 10! >> >> The answer is almost instantaneous. > >Wolfram Alpha is merely approximating the result to a certain >precision. I highly doubt it's actually calculating the whole number >and then just stripping off the first N digits! Stirlings approximation. The version I posted earlier used a form of it as well. There are also formulas for the other values Wolfram gives. -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: defmulti - defonce semantics?
use of immigrate is unhygienic and a problem to be solved before you go looking for others On Thu, Jul 15, 2010 at 11:07 AM, Pedro Teixeira wrote: > On Jul 14, 4:09 pm, Michał Marczyk wrote: >> If you're ok with discarding all your methods for the given multi, you can do >> >> (ns-unmap the-ns-of-defmultiname-of-the-multimethod) >> >> (I'm not sure if you should also unmap it in namespaces which refer to >> that Var just now...) >> >> Then the entire multifunction will be recreated when you recompile. > > Hi, perhaps someone has already stumble upon this issue: > > For some reason, when using immigrate, defmethod is not working. that > is, defmethod inside a namespace which 'use a namespace which > 'immigrate a defmulti does not seem to a dispatch function to the > (methods 'multimethod). > > Does it make sense? > > regards, > Pedro > > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Implementing a protocol with using a base implementation?
Hi Nicolas, I get the idea, but I don't see how this would help provide a default implementation for the functions inside a protocol. It looks to me like this would be the same as creating a record with only some of the functions implemented. Or am I reading it wrong? Thanks for your input. Toni. On Fri, Jul 16, 2010 at 1:21 PM, Nicolas Oury wrote: > I read my mail and couldn't understand it. > Here is what I meant: > (defprotocol MessageReceived > (message-received ...)) > (defprotocol ExceptionCaught > .) > (extend Object MessageReceved {:message-received > default-message-received-function}... > ) > (deftype channel-handler > ExceptionCaught ) > (not the lack of message received implementation) > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- Antoni Batchelli - twitter: @tbatchelli , @disclojure --- email: tbatche...@gmail.com - web: tbatchelli.org , disclojure.org -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ClojureDocs.org
Hi Zack, I just take a quick look at your site and must say that I'm impressed. This is going to become one of the utilities I constantly keep open in the background while developing. Especially since features like the Var cross-referencing tend to make easier to get the "big picture". One thing I immediately wanted to do is browse the Enlive docs to learn about the templating code, but couldn't simply search for "Enlive" -- I had to either click the (less-visible) "All libraries" link or search for a known Var like "defsnippet". A project search feature, or a unified search that will search in Vars as well project names, would be really helpful. Thanks for investing your time into this site. May it prosper and attract many prospective new Clojure developers :-) -Daniel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: defmulti - defonce semantics?
On Fri, Jul 16, 2010 at 6:20 PM, Kevin Downey wrote: > use of immigrate is unhygienic and a problem to be solved before you > go looking for others > didn't realize it before. I already started to remove it from code, and declaring all :uses explicitly. thanks for the reply. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Function called from macro loses record structure
This is an instance of the broader issue whereby records currently evaluate to maps. There was a ticket open for that on Assembla. I'm not sure what's the current status on that, but whenever it gets fixed, macros will be able to use records in their expansions. Sincerely, Michał -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ClojureDocs.org
A few thoughts... It might be interesting to allow examples to be rated. Quality or usefulness of the provided example could then be inferred from the rating and highly rated examples could bubble to the top or have the associated rating prominently shown. ~A On Jul 16, 10:29 am, Lee Hinman wrote: > Had another suggestion, > > As an example contributor, It would be really nice to see a list of > functions that have no examples yet at a glance, so if I wanted to > work on adding examples I could go through a list and work on > functions that have no examples. I believe the clojure-examples > appspot wiki used to dim out functions that didn't have any examples > (I don't think it does this any more), which was very helpful. > > If we did this, we could even have a percentage meter to work toward > 100% API example coverage :) > > - Lee -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
A functional, efficient, convolution function. Is imperitive-style the answer?
I posted this on StackOverflow yesterday, but to no avail: I don't think many people looked at it, or least I didn't get much feedback. I am trying to create a lazy/functional/efficient/Clojuresque function to carry out convolution on two lists/vectors of (ideally BigDecimals but that may be inefficient) doubles. It is turning out to be very difficult. I have four or five versions in my buffer right now, and none of them are acceptable. I've even tried a number of versions using into-array etc, e.g. mutables. Instead of posting a lot of links to pastie, I'm just copying the SO link here, where my code and the algorithms can be found. Right now, it seems as though this is something Clojure cannot do. David Nolen mentioned that the appropriate Java-interop functionality may come in Clojure 1.3, but aside from eschewing the functional style by using arrays, it seems as though there should be a better answer. (As an aside, where can I find out about 1.3?) I have a Python implementation to show how nicely it can be expressed in an imperitive language (though I suppose I dabbled in the functional style initializing my return array). Is it possible to do this, and do it well? Thank you so much, in advance. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Question on namespace/packages of defrecord
Congrats on the 1.2 beta guys! When I AOT a defrecord it does not javaize the clojure namespace into a proper java package name. (ns this-that) (defrecord Fred []) ;creates a class file this-that.Fred.class Is this by design? What is the thinking here? Thanks, Eric -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: A functional, efficient, convolution function. Is imperitive-style the answer?
Where's the link? :) -Fred -- Science answers questions; philosophy questions answers. On Jul 16, 2010, at 2:57 PM, Isaac Hodes wrote: > I posted this on StackOverflow yesterday, but to no avail: I don't > think many people looked at it, or least I didn't get much feedback. > > I am trying to create a lazy/functional/efficient/Clojuresque function > to carry out convolution on two lists/vectors of (ideally BigDecimals > but that may be inefficient) doubles. > > It is turning out to be very difficult. I have four or five versions > in my buffer right now, and none of them are acceptable. I've even > tried a number of versions using into-array etc, e.g. mutables. > > Instead of posting a lot of links to pastie, I'm just copying the SO > link here, where my code and the algorithms can be found. > > Right now, it seems as though this is something Clojure cannot do. > David Nolen mentioned that the appropriate Java-interop functionality > may come in Clojure 1.3, but aside from eschewing the functional style > by using arrays, it seems as though there should be a better answer. > (As an aside, where can I find out about 1.3?) > > I have a Python implementation to show how nicely it can be expressed > in an imperitive language (though I suppose I dabbled in the > functional style initializing my return array). > > Is it possible to do this, and do it well? > > Thank you so much, in advance. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: A functional, efficient, convolution function. Is imperitive-style the answer?
I'm assuming the StackOverflow link you refer to is http://stackoverflow.com/questions/3259825/trouble-with-lazy-convolution-fn-in-clojure. I would think about the problem this way: to compute the value at index i in the output list, you multiply together each pair of values in the input lists whose indices add up to i, then add them all together. So I would first write a small helper function to return a list of such index pairs for a given output index, then use it with map to compute each output value in one go. (defn convolve-indices [i max-m max-n] "Lists all index pairs adding up to i, where the first index is less than max-m and the second is less than max-n." (filter #(< (first %) max-m) (filter #(< (second %) max-n) (map #(vector % (- i %)) (range (inc i)) (defn convolve-1 [i ms ns] "Returns the ith value of the convolution of ms with ns." (reduce + (map #(* (ms (first %)) (ns (second %))) (convolve-indices i (count ms) (count ns) (defn convolve [ms ns] "Convolves ms with ns." (map #(convolve-1 % ms ns) (range (dec (+ (count ms) (count ns)) I would expect this to be much slower than the imperative approach, due to all the temporary objects and the lack of type hints. There should be a much less wasteful way to write convolve-indices, for instance. On the plus side, you may be able to use pmap to parallelize the work with little effort. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en