Re: Timed caches?
On Sat, Sep 18, 2010 at 10:40 AM, Sean Corfield seancorfi...@gmail.com wrote: Since memoize seems to be 'forever' and caching in general smells of mutable state, I wondered how folks are tackling this sort of thing in Clojure? Are you simply dropping down to Java libraries and being 'non-functional' or is there some more idiomatic approach available? I think memoization in clojure(and other language like Haskell) at the language level is mainly used for speeding up algorithm, like the famous finbonacci number sequence in Haskell and not as a cache feature. In other words, the memoization will disappear outside the function call. caching as in web application is a completely different thing which i would use whatever is needed for the application(memcache for example). -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: partition-starting-every : yet another partition function
On Fri, Sep 17, 2010 at 10:49 AM, Nicolas Oury nicolas.o...@gmail.com wrote: I was just saying that not returning something that is a pair, for example nil, is good enough. The implement is equivalent, most languages I know that has unfold use your approach(i.e. return Maybee,s or None). This link use the unfold p f g form http://webcache.googleusercontent.com/search?q=cache:ksRX1JVmxFgJ:www.comlab.ox.ac.uk/jeremy.gibbons/publications/unfold.ps.gz+unfold+p+f+gcd=5hl=enct=clnkgl=ca -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Simple things should be simple
On Fri, Sep 10, 2010 at 4:47 AM, John Cromartie jcromar...@gmail.com wrote: #!/usr/local/bin/clj (println Content-type: text/plain\n) (println Hello, World!) ^D Is that simple enough? That was my thought too, java/clojure console app should not be more complex than python etc. The issue is the startup time For better startup performance, you can use Nailgun. How can nailjun help here ? I am not too familiar with it. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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 and the Computer Language Benchmarks Game
On Fri, Sep 10, 2010 at 8:49 AM, Isaac Gouy igo...@yahoo.com wrote: Huh ? point ? it was just a casual comment, no point was intended. And I have read some comments by Don that what is in the shoutout is way faster than Data.HashTable If you knew there was another option why write I doubt there is any choice for Haskell ? That was referring to the original comment about 'making a mutable implementation' meaning the program itself ASKED for that particular functionality. The one in the shoutout is one implementation of it, the one in Data.HashTable is another. When I said no choice, I was saying no choice but to implement a mutable hash table, in respond to the underlying message of 'why did they implement a mutable hashtable' as if making it mutable is only for performance purpose. And Data.HashTable also use some mutable array thing so it is still not the idiomatic Haskell of everything is immutable. afaict idiomatic is everything referentially transparent not everything immutable, as in - I needed a halfway decent mutable collection type – having a properly tested mutable collection that actually performs well would be a godsend. how can you assure that(let's put aside the under the hood things where it is done in C) if you break the assumption that value can be changed. Reading the first paragraph Introduction to Uniqueness Typing of this paper should help you with that question - http://www.st.cs.ru.nl/papers/2008/vrie08-IFL07-UniquenessTypingSimplified.pdf Would try to digest that. I'm not going to speculate about what unnamed verteran Haskellers have or have not said. Read the bug report and you'll see that the root problem was GC - do you think changing GC is a quick fix? Don suggested on reddit for some fixes that tackle the GC issue(not changing the GC, but the way to get around the performance caused by GC), using similar approach as in the shoutout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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 and the Computer Language Benchmarks Game
On Fri, Sep 10, 2010 at 11:13 AM, Isaac Gouy igo...@yahoo.com wrote: Clearly, they did choose to write all that code in order to get a much faster program - I can't tell you if Andy had noticed the benchmark was about Hashtable update and k-nucleotide strings or whether he knew about Data.HashTable. I know they did it to get a faster program, but under the requirement of : IT MUST BE MUTABLE HASHTABLE If you change the requirement to something else that acheives the end result without this specific requirement, they may not use hashtable at all. Which is also the message I get from various place like reddit or stackoverlow about this same issue. That is 'use your language's strength to solve the problem, not to mimic other language, i.e. the what not the how'. And this sentiment is not unique to Haskell. I recently saw similar questions on J language of 'how can I write a Haskell style filter(HOF)', the overall answers there are 'you don't need haskell style filter and can achieve the same result in a J way'. Similarly for Haskell which is 'you don't need to use mutable hash table and can very likely get the same result using other immutable data structure' But in this case the problem is 'implement a mutable hashtable' which is what my 'no choice' was referring to. Unlike language say Python or F# where hash table is in general considered to be part of the language, Data.HashTable is not. It is just one 'sample' of implementation of mutable hash table which happens to be slow. And Data.HashTable also use some mutable array thing so it is still not the idiomatic Haskell of everything is immutable. afaict idiomatic is everything referentially transparent not everything immutable, as in - I needed a halfway decent mutable collection type – having a properly tested mutable collection that actually performs well would be a godsend. how can you assure that(let's put aside the under the hood things where it is done in C) if you break the assumption that value can be changed. Reading the first paragraph Introduction to Uniqueness Typing of this paper should help you with that question - http://www.st.cs.ru.nl/papers/2008/vrie08-IFL07-UniquenessTypingSimpl... Would try to digest that. Bite-sized: An important property of pure functional programming languages is referential transparency: the same expression used twice must have the same value twice. A side effect on a variable (file) is okay as long as that variable is never used again: it is okay for a function to modify its input if the input is not shared. Referential transparency then trivially holds because the same expression never occurs more than once. Rather than just returning the read character, fgetc returns a pair consisting of the read character and a new file, file1. Although file0 and file1 point to the same file on disk, they are conceptually and syntactically different, and thus it is clear that a and b may have different values. I read this part, trying to fit that into this mutable hashtable context. Below this paragraph, it mentioned some requirement/assumption that file0, file1 ... cannot be 're-used' which I don't know how to apply to hashtable. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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 and the Computer Language Benchmarks Game
On Fri, Sep 10, 2010 at 2:04 PM, Isaac Gouy igo...@yahoo.com wrote: It's starting to look like actually there was a point you wanted to make ;-) You mean the 'no chice' part ? yes. You mean the why not Data.Hashtable comment ? I don't think so. If you change the requirement to something else you'd simply be missing the point - which was to look at hashtable updates and strings. I know perfectly well what you want to measure and I was not implying if those measure is valid or not, I am totally neutral to the whole thing. My initial comment was all about 'it seems that Haskell submission is not the typical elegant form' and to me because of the specific you want to measure, there is no acceptable elegant Haskell form. Does it actually say that the hashtable updates have to be destructive? If want to go that route, be my guest. There's no choice in binary-trees either - you must use binary-trees and you must allocate all the memory. There's no choice in pi-digits either - you must use that particular step-by-step spigot algorithm taken from that Haskell paper. There's no choice in fannkuch-redux either - you must use that particular ordering of permutations taken from that Lisp paper. etc etc Indeed. Your benchmark suite are very specific about how certain things must be done in order to measure a specific aspect you want to measure. Forgive me but you do seem to be belabouring the obvious. I think you are too sensitive -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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 and the Computer Language Benchmarks Game
On Fri, Sep 10, 2010 at 3:06 PM, Isaac Gouy igo...@yahoo.com wrote: So what are we to do when there's a problem that has no acceptable elegant Haskell form? Depending on the intend, for you benchmark program, write something like what it is now. For real life cases, call an exnternal library, use another language, transform the solution into something that would not hit the weak point of the language(I recently saw an example of this on J about a simple but interesting quiz). Does it actually say that the hashtable updates have to be destructive? If want to go that route, be my guest. I don't understand what you mean, didn't you say - it must be a mutable hashtable? Why couldn't it be a hashtable that copied values? As I said, be my guest. Indeed. Your benchmark suite are very specific about how certain things must be done in order to measure a specific aspect you want to measure. The other complaint is that it's not specific enough and allows too much play, with programs in one language being too different to programs in other languages. not sure what you want to say. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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 and the Computer Language Benchmarks Game
On Thu, Sep 2, 2010 at 6:07 PM, John Fingerhut andy.finger...@gmail.com wrote: Some of the Haskell submissions are quite long for what they do. The k-nucleotide one, for example, implements a mutable hash table using features in Haskell that I had never seen before looking at that program. Did they need to write all of that code to solve the problem? No. Did they choose to, in order to get a much faster program that would be more competitive in run time versus other languages. Definitely. Is it the requirement for that particular program to handle hash table (to test in place update) ? That seems to be the message I get from the description of the program. If that is the case, I doubt there is any choice for Haskell. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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 and the Computer Language Benchmarks Game
On Thu, Sep 9, 2010 at 7:02 PM, Isaac Gouy igo...@yahoo.com wrote: iirc the Haskell programs, and the Clean programs, and the Pascal programs, and ... use translations of the simple hash table used by the C programs. If I ever knew, I don't recall why the Haskell program does not use Data.HashTable Could be that it wasn't there at the time it was submitted. And Data.HashTable also use some mutable array thing so it is still not the idiomatic Haskell of everything is immutable. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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 and the Computer Language Benchmarks Game
On Thu, Sep 9, 2010 at 10:04 PM, Isaac Gouy igo...@yahoo.com wrote: Is there any point speculating about this as outsiders? It was available - Data.HashTable seems to be copyright 2003. http://ogi.altocumulus.org/~hallgren/Programatica/tools/pfe.cgi?Data.HashTable Huh ? point ? it was just a casual comment, no point was intended. And I have read some comments by Don that what is in the shoutout is way faster than Data.HashTable And Data.HashTable also use some mutable array thing so it is still not the idiomatic Haskell of everything is immutable. afaict idiomatic is everything referentially transparent not everything immutable, as in - I needed a halfway decent mutable collection type – having a properly tested mutable collection that actually performs well would be a godsend. how can you assure that(let's put aside the under the hood things where it is done in C) if you break the assumption that value can be changed. BTW, it seems that to verteran Haskellers, the speed of Data.HashTable is not a concern to them as they said they don't see the need of that(mutable hasktable) in their usage. There seems to be a bug(as in it is slow) filed for this package for quite a while but no one even bother to attempt to improve it. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Mapping a function to a map
On Mon, Sep 6, 2010 at 9:49 AM, Robert McIntyre r...@mit.edu wrote: I thought that since into uses reduce, it would be lazy, but I was wrong. reduce just plows through everything with a non-lazy recursion. Why is reduce not lazy? reduce in clojure == foldl in Haskell and as far as I know, there are very rare use cases for lazy foldl. The general rule of thumb in Haskell is use foldl'(strict version) or foldr(lazy). That may explain why reduce is not lazy. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Mapping a function to a map
On Mon, Sep 6, 2010 at 10:09 AM, Justin Kramer jkkra...@gmail.com wrote: reduce returns a single value; there's no collection to make lazy. There is reductions, which returns the intermediate results of reduce as a lazy sequence. if f = cons in 'reduce f a seq', there is a collection. Though in this case, one should use foldr rather than foldl. That lead to a question I have asked before, is there a lazy foldr in clojure ? A related question, what about unfold ? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Mapping a function to a map
On Mon, Sep 6, 2010 at 10:47 AM, Robert McIntyre r...@mit.edu wrote: Why is it that clojure maps aren't lazy though? Wouldn't that be just as useful an abstraction as lazy sequences? Aren't map really just lists of pairs in the end anyway? how can laziness benefit map usage pattern ? efficient search requires the keys to be in some form of balanced tree(?) so everything needs to be realized while building the tree ? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Web Development - templating?
On Wed, Sep 1, 2010 at 11:58 AM, Laurent PETIT laurent.pe...@gmail.com wrote: The ideal setup, in my opinion, after using all sorts of different web frameworks and languages over the last 14 years, is to have all the HTML in the template - code never generates HTML - and to have *some* markup in the HTML template to allow: * dynamic variable substitution * conditional selection * looping * including other templates (or some sort of 'wrapping' to make layouts with common elements easy to work with) Interestingly, after reading the above bullets, I first thought you were describing what enlive is doing ! :) I thought most template system are doing these, one way or another. The devil is in the detail though. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Why Jetty? (web development)
On Wed, Sep 1, 2010 at 7:46 PM, Sean Corfield seancorfi...@gmail.com wrote: If not, how do you build a Clojure web app that runs on Tomcat / JBoss / etc? (so the underlying question is: what's the raw Servlet implementation that folks use to power Clojure-based web apps on containers other than Jetty?) -- That in general is not a problem about the container but clojure itself. I see the same problem for Microsoft's F#. That said, I have no problem using clojure and put it on Google's app engine(which is java) by just subclass the request object(or something like that), the plain old servlet way. What is difficult would then be about layout, templating etc. For serious web development, I would say both clojure and F# would be better to serve in the 'business logic' side as the eco-system surrounding java/c# is way ahead of clojure/F#. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: trouble with NetBeans install
On Mon, Aug 30, 2010 at 3:57 PM, Mark Nutter manutte...@gmail.com wrote: This may or may not be related, but I had similar problems when I tried to install from the downloadable .nbm file for enclojure. I solved it by poking around the enclojure.org site -- there's instructions for updating the plugins setup screen so that you can install/update enclojure using the built-in automatic install/upgrade interface. I can give you more information if that's close but not quite enough. just be reminded that the auto install/upgrade package url only supports 6.9 and would result in similar dependency error when used under 6.8 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: I don't understand this method
On Sat, Aug 28, 2010 at 8:37 AM, HB hubaghd...@gmail.com wrote: Ok, I understand what it does but I don't understand -yet- how it is works. Why vector and its parameters aren't in ( ) ? What are the parameters to the vector and what are the parameters to the map in the example? vector is used as a 'function object' for map. signature of map map function list1 list2 - ( (function list1_e1 list2_e1) (function list1_e2 list2_e2) ) in this invokation, function = vector -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: 1.2 contrib shuffles
On Fri, Aug 27, 2010 at 7:02 AM, B Smith-Mannschott bsmith.o...@gmail.com wrote: What test failures are you seeing? I'm not seeing any building github.com/clojure/clojure-contrib 1.2.0-RC3 (e4ea06c9ff93df3b3f667ab5768618ece5a98b6e). Ran 365 tests containing 1298 assertions. 0 failures, 0 errors. I need to exclude/modify a few test when running under windows, due to the crlf vs cr stuff -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: 1.2 contrib shuffles
On Fri, Aug 27, 2010 at 8:17 AM, Btsai benny.t...@gmail.com wrote: How are you grabbing the sources? I'm also running under Windows, and get the source from github via msysgit, which handles the crlf vs. cr issue nicely. same here. that only handles the source crlf I assume. What I did was specifically for the test itself. though that was a while ago(about 2 months back). didn't bother to try with the latest. may be the test has been changed. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: misunderstanding collection
On Wed, Aug 25, 2010 at 7:06 AM, Glen Rubin rubing...@gmail.com wrote: After toying around at the REPL I realize that I have been working with a heretofore invalid understanding of collections. For example, working with the following collection(s): signal: (((1 2 3 4) (2 3 4 5) (3 4 5 6)) ((3 4 5 6) (4 5 6 7) (5 6 7 8))) I wanted to sum each individual list: e.g. (1 2 3 4) = (10) I thought I could do this as follows: (map #(map reduce + %) signal) This resulted in an error, so trying to comprehend why I ran the following: (map #(map identity (take 1 %)) signal) which results in, (((1 2 3 4)) ((3 4 5 6))) So, clojure sees 'signal' as 2 collections, whereas I thought it was a single collection. This makes me concerned that I have been doing everything wrong thus far and getting computational errors. :( So, how should I sum each individual list in the above collections? I would suggest you to learn either F#(the IDE is the best) or Haskell in parallel. Both of them are typed language which would give you a better clue of what is going on here and the map/reduce thing is basically the same. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: trouble using nested map fn
On Mon, Aug 23, 2010 at 8:31 AM, Luka Stojanovic li...@magrathea.rs wrote: It's not about nested maps, but about nested anonymous functions: if you nest anonimous functions you must use (fn [] ...) like: (map (fn [t s] (map #(map * %1 %2) t s)) target signal) This has me question, how useful the #(...) form is as clojure's lambda form i.e. (fn [t s] ...) is already very clean and it conveys more information of what it is than the relatively cryptic %1 %2 ... -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: trouble using nested map fn
On Mon, Aug 23, 2010 at 8:50 AM, Joop Kiefte iko...@gmail.com wrote: uses like #(first %) keeps the code cleaner Is that the same as just 'first' like : (map first [[1 2] [3 4]]) (map #(first %) [[1 2] [3 4])) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: trouble using nested map fn
On Mon, Aug 23, 2010 at 8:26 AM, Glen Rubin rubing...@gmail.com wrote: I am trying to write a fn to correlate 2 signals using 3 nested map fn. I have 2 collections of data. THe first group of signals called target looks something like this. target: ( (1,2,3,4) (2,3,4,5) ...) The second collection is called signal and looks like this: signal: ( ((1,2,3,4)(2,3,4,5)(3,4,5,6)) ((2,3,4,5)(3,4,5,6)(4,5,6,7)) ... ) I would like to take the first list in target and multiply it by every list in the first group of signal. And then continue on processing the second list, etc... which would result in something like: ( ((1,4,9,16)(2,6,12,20)(3,8,15,24)) ((4,9,16,25) (6,12,20,30) (8,15,24,35)) ... ) I try a nested map fns like this, but can't get it to work: (map #(map #(map * %1 %2) %1 %2) target signal) -- BTW, I think using the (for ...) construct is cleaner and is a faithful translation of your intend. (map #(for [s %2] (map * %1 s)) target signal) Though personally I still think the %2 %1 is a bit confusing. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: trouble using nested map fn
On Mon, Aug 23, 2010 at 5:41 PM, Randy Hudson randy_hud...@mac.com wrote: Well, #(= lo % hi) is to my mind much more readable than (fn [x] (= lo x hi)), especially embedded in another form or two (as it would be). that may be true. though this IMO is partly due to the (=) construct's argument order. This is the case where it is a single argument function yet you need to explicitly spell that out as it is in the middle. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Processing large binary file?
On Sat, Aug 21, 2010 at 10:32 AM, Nicolas Oury nicolas.o...@gmail.com wrote: I am not sure but I think filter will always output a sequence. filter is lazy but the function like (byte-array ..) would still realize the sequence(i.e. list created) then copy. (byte-array (count (filter ...)) (filter ...)) should work, at the expense of filter twice. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: looking for a simpler implementation of a function I'm using
On Sun, Aug 8, 2010 at 10:32 PM, Meikel Brandmeyer m...@kotka.de wrote: I'm bit confused about what you mean here, but vector append (read: conj) is O(1) (don't nail me down on whether it's amortised). There is no array copying going on underneath. Assuming vector is implemented in some form of array(well it seems to have the characteristic of an array where accessing any element would be O(1)), appending one element can be O(1) if there are space reserved for some extra items but if that action is repeated till the slack is filled up, some form of re-shuffling is needed. This compares to a single link list which is just a nested cons. So I fail to see how it can be O(1) in the cons sense where no reshuffling would occur no matter how many cons are there. As I said, I am not questioning the performance difference(I am pretty sure it is very efficient), but curious. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: looking for a simpler implementation of a function I'm using
On Sun, Aug 8, 2010 at 10:50 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Aug 8, 6:19 pm, gary ng garyng2...@gmail.com wrote: I wrote a similar version in F# which does have the advantage of handling infinite input or a very long partition in the sense that I can still consume the first element immediately and can skip to the second, third group ... In a sense, the result is a lazy list of lazy list and if the consumer doesn't hold on to any of them, the memory usage is constant. I don't think it is possible to do this. At least not in a functional way. Assume your first item of the resulting sequence is a lazy sequence representing the first group. To define the rest of the sequence you have to know the end of the first group in the input sequence. However this can only be found by traversing the input sequence. So this must again be some lazy sequence like a drop-while or so. But no matter how it is directly implemented, it must retain the head of the input sequence for traversal. So, if I traverse the first group, its items cannot be GC'd because of the rest definition of the sequence. But the same holds true if I skip to the second group without realising the first one: to find the actual second group I have to realise the rest of the sequence, which will also realise the items of the first group. So there is no point in not realising the groups: its done anyway, no matter what. You just introduce unnecessary laziness overhead. Yes and No. I have experiemented it a bit back when I was doing it and in certain cases, there are some advantages(mostly in memory usage) even though the front of the list still needs to be realized. Say I want the 'head of each group'. I think the Haskell implementation has this characteristic too. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Please help! Really simple function not working.
On Mon, Aug 9, 2010 at 5:24 PM, Carlos Torres carlos.torr...@upr.edu wrote: Hi to everyone, I'm trying to create a function that takes a simple list and returns the number of zeros in the list. So I'm assuming that they will enter a list containing only numbers. This is what I have so far, but it only works when the list empty. Can somebody tell me what I'm missing? (defn count-zeros Returns the numbers of zero in a simple sequence of numbers [list1] (cond (empty? list1) 0 (not (zero? (first list1))) 0 :else (recur (+ 1 (count-zeros (rest list1)) --Carlos I believe your second codition break the recursion but in general, don't write your own unless you are learning how to write recursive code in clojure. this is textbook filter then count or foldl(i.e. reduce). -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: take-while2?
On Sat, Aug 7, 2010 at 8:56 PM, Michał Marczyk michal.marc...@gmail.com wrote: Yet another version: (defn take-while-acc [f pred coll] (map (fn [_ x] x) (take-while pred (reductions f coll)) coll)) Seems to work: user (take-while-acc + #( % 100) (range)) (0 1 2 3 4 5 6 7 8 9 10 11 12 13) Note that reductions does use an accumulator (in the form of a closed over local), so the above works as requested. Also, this version constructs no auxiliary data structures, not even two-element vectors. Ah nice, map in clojure can also function as zipWithN thus using the original position in place of the two-element vector. I was looking for where is zipWith in clojure. 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
Re: looking for a simpler implementation of a function I'm using
On Sun, Aug 8, 2010 at 12:12 AM, Meikel Brandmeyer m...@kotka.de wrote: Just for fun another low-level solution: (defn partition-when [pred coll] (let [step (fn [p s] (if s (let [fst (first s)] (if (pred fst) [p s] (recur (conj p fst) (next s [p nil]))] (lazy-seq (when-let [s (seq coll)] (let [[p r] (step [(first s)] (next s))] (cons p (partition-when pred r))) Hopefully not holding onto the head, as lazy as it can get and working with infinite input. I wrote a similar version in F# which does have the advantage of handling infinite input or a very long partition in the sense that I can still consume the first element immediately and can skip to the second, third group ... In a sense, the result is a lazy list of lazy list and if the consumer doesn't hold on to any of them, the memory usage is constant. It is slower than a non-lazy version in F# when the input is not too long in size. I don't know about the characteristic of the current partition-by in core, as this version would be a nice addition for its capability of handling long input effectively. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: looking for a simpler implementation of a function I'm using
On Sat, Aug 7, 2010 at 9:30 PM, David Cabana drcab...@gmail.com wrote: conj is not the same as append; it will insert the new element in the smart (most efficient) way. For instance: user (conj '(1 2 3) 0) (0 1 2 3) user (conj [1 2 3] 0) [1 2 3 0] There is no performance hit from using conj to insert at the end of a vector. Interesting to know. Just curious which one is more efficient(not that I question the vector append is slow) as it would still involve some array copy and creation(though I assume it would be very efficient as it is using the very low level i.e. sort of memcpy) whereas the single-link-list cons would always be O(1). -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: take-while2?
On Sat, Aug 7, 2010 at 8:14 AM, Steve Purcell st...@sanityinc.com wrote: Oh, right, so maybe: (last (take-while #( (apply + %) 100) (reductions conj [] (iterate inc 0 = [0 1 2 3 4 5 6 7 8 9 10 11 12 13] -Steve or user= (map second (take-while (fn [e] ( (first e) 100)) (rest (reductions (fn [a x] [(+ (first a) x) x]) [0 0] (iterate inc 0) (0 1 2 3 4 5 6 7 8 9 10 11 12 13) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: take-while2?
On Sat, Aug 7, 2010 at 12:46 PM, Steve Purcell st...@sanityinc.com wrote: Nice - that's about twice as fast as my version (with the 100 limit scaled up to 1 million), though perhaps a less general pattern since the code structure assumes knowledge of +'s cumulative nature. Yes, it needs a proper initializer(or Zero() in monad speak) which needs to be passed in to make it generic. What it does is simply carrying the accumulator in the sequence as a tuple(or vector in clojure term, I am still more familar with Haskell/F#) so the accumulator can be anything. There was a quirk where I need a [0 0] which can be fixed in the following: user= (map second (take-while #( (first %) 100) (reductions #(vector (+ (first %1) (first %2)) (first %2)) (map #(vector % %) (iterate inc 0) (0 1 2 3 4 5 6 7 8 9 10 11 12 13) here the #(vector % %) kind of work around by producing the initializer, assuming the accumulator and the element are the same type. If this assumption doesn't hold, it would become: (map #(vector Zero(%) %) collection) where Zero(%) needs to be something that produce the initializer, say (list) if the accumulator is a list. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: take-while2?
On Sat, Aug 7, 2010 at 10:44 AM, Andreas Liljeqvist bon...@gmail.com wrote: Thanks that works. What I really want is a function like in my initial posting. Is there something like that in core or contrib? Your example code can be quite slow since all sublists are summed before comparision. I believe my version is doing what you are asking. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: looking for a simpler implementation of a function I'm using
On Sat, Aug 7, 2010 at 6:12 PM, David Cabana drcab...@gmail.com wrote: Speed is no big deal for me; the sequences I'm handling are short, say about length100. BTW, one of these is considerably faster than the other for longish sequences. Can you guess which? if you don't mind about performance, this seems to be natural to me user= (reverse (map reverse (reduce (fn [a e] (if (even? e) (cons [e] a) (cons (cons e (first a)) (rest a (list) [1 2 3 7 5 4 1]))) ((1) (2 3 7 5) (4 1)) Othewise, I would look for a foldr solution. Talking about foldr, is it in 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
Re: looking for a simpler implementation of a function I'm using
On Sat, Aug 7, 2010 at 6:35 PM, Michael Gardner gardne...@gmail.com wrote: (partition-by #(when (even? %) (gensym)) nice, why do I need the gensym ? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: looking for a simpler implementation of a function I'm using
On Sat, Aug 7, 2010 at 6:39 PM, gary ng garyng2...@gmail.com wrote: On Sat, Aug 7, 2010 at 6:35 PM, Michael Gardner gardne...@gmail.com wrote: (partition-by #(when (even? %) (gensym)) nice, why do I need the gensym ? ah, the gensym is for 'break'. but why does it behave like this user= (partition-by #(when (even? %) (gensym)) [1 2 3 7 5 4 1] ) ((1) (2) (3 7 5) (4) (1)) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: looking for a simpler implementation of a function I'm using
On Sat, Aug 7, 2010 at 6:55 PM, Michael Gardner gardne...@gmail.com wrote: On Aug 7, 2010, at 8:48 PM, Michael Gardner wrote: On Aug 7, 2010, at 8:39 PM, gary ng wrote: nice, why do I need the gensym ? The gensym was just a cheesy way of generating a unique value. To elaborate a bit more on my failure, I was reading the docs for partition-by thinking that new value meant a value not before seen, not simply a different value from the previous one. Then I accidentally hit 'send' before I could test it and realize my mistake. Using your partition-by help, this is what I come up user= (map (fn [l] (map second l)) (partition-by first (rest (reductions (fn [a e] [(if (even? e) (gensym) (first a)) e]) [(gensym)] [1 2 3 7 5 4 1] ((1) (2 3 7 5) (4 1)) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: looking for a simpler implementation of a function I'm using
On Sat, Aug 7, 2010 at 8:27 PM, David Cabana drcab...@gmail.com wrote: Using a vector instead of a list as the accumulator makes it possible to skip the mapping of reverse used in the earlier version of pw: (defn pw [f? x] (let [phi (fn [a e] (if (f? e) (cons [e] a ) (cons (conj (first a) e) (rest a] (reverse (reduce phi [] x conj sounds like 'append' to me which I have no idea about the performance characteristics in clojure(it is a no-no in F#, Haskell ++ is better but would grow the stack). list cons then reverse would give me predictable O(2n). That is why I usually rather go for the cons then reverse route. thanks for the example BTW, as I am learning my clojure basics via these excercises. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Efficiency of reduce function for lists.
On Sat, Jul 24, 2010 at 3:16 PM, samnardoni samnard...@googlemail.com wrote: I have a simple string (or list of characters to be precise) in a form of: 123456789. I want to parse this string and end up with: 123569. The is essentially the same as a backspace. I think reduce(or fold/foldl' in Haskell/F#) fits perfectly here. I am not too familiar with clojure syntax, the equivalent F#(and more or less the same in Haskell): let del (s:string) = let x = List.fold (fun a x - if (x = '') then List.tail a else x::a) [] (List.ofSeq s) | List.rev | List.toArray new System.String(x) basically it just turn the string into list of char(native if in Haskell) and use the very efficient cons(::)/tail operation in the fold and do a reverse at the end. This also handles 'over deletion' as 'tail of [] - []'. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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?
J(a language of the APL family) excels at this problem domain. It is functional and very efficient. conv =: +//@*/ It looks like line noise but that is the whole implementation (1 1 ) conv (1 1) = 1 2 1 http://www.jsoftware.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: Easier way to run Clojure from command line?
On Sat, May 8, 2010 at 9:20 AM, Adam Jones ajon...@gmail.com wrote: Have you seen Leiningen? [1]. It seems like it will do what you want with lein repl, and additionally it has some nice features for acquiring dependencies and building a .jar from your project. [1] http://github.com/technomancy/leiningen#readme leiningen is even more complicated than clojure in a windows environment :-) First, you need to install maven2 which don't have installer meaning you need to go around with changing the PATH Then you need to find out your personal .m2 repo location and manually download the leniningen jar to there(and also the clojure jars too) Then you need to download the sort of 'experimental' lein.bat and you can do that 'lein repl' command. In general, java based command line utilities(ant, maven etc.) are very intimidating in windows environment. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: code review:replace-first
I would use reductions(i.e. Haskell's scanl) given my understanding that clojure sequence is just as lazy as Haskell. (rest (map first (reductions (fn [ [v a b] x ] (if (= a x) [b nil b] [x a b])) [nil 2 3] '(1 1 2 2 3 4 I use nil here as 'something that would not appear in the list', I am sure there are better marker if 'nil' is a valid value. If there is a foldr in clojure, it is also possible to short circuit the rest of comparison once the first is found. The other possibility is using 'unfold', I am not quite familiar with clojure's sequence functions. There may be one already, using some other names. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: code review:replace-first
On Sat, May 8, 2010 at 1:01 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, if you want to go low-level you can use lazy-seq. (defn replace-first [needle replacement coll] (lazy-seq (when-let [s (seq coll)] (let [fst (first s)] (if (= fst needle) (cons replacement (rest s)) (cons fst (replace-first needle replacement (rest s Hi Meikel, I would love to see this generalized to become a lazy foldr in clojure, which is one of the frequently used(abused) HOF. The unfold I mentioned is another very useful HOF. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Easier way to run Clojure from command line?
On Sat, May 8, 2010 at 4:00 PM, Anne Ogborn annie6...@yahoo.com wrote: Have you seen Leiningen? [1]. It seems like it will do what you want with lein repl, and additionally it has some nice features for acquiring dependencies and building a .jar from your project. Unfortunately lein repl is apparently broken on windows. Works for me. Microsoft Windows [Version 6.0.6002] Copyright (c) 2006 Microsoft Corporation. All rights reserved. C:\Users\garylein repl Clojure 1.1.0 user= quit java.lang.Exception: Unable to resolve symbol: quit in this context (NO_SOURCE_F ILE:0) user= ^Z -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: last-var-wins: a simple way to ease upgrade pain
On Wed, May 5, 2010 at 10:34 PM, Meikel Brandmeyer m...@kotka.de wrote: I'm deeply suspicious of such a behaviour. Why would + on a date mean adding days? Why not hours? minutes? seconds? months? years? I would always prefer plus-days over such a behaviour, because I wouldn't have to think everytime, what + adds. But that is only a matter of taste, I fancy. Convention, mostly. Say in the security trading settlement world, they use terms like T+3 to mean transaction date + 3 days. Which is why I said, toy DSL. It is used in an implicit context. Everyone in that business knows what T+3 means. Just like we know what CC means when looking at email. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Restricted eval
On Thu, May 6, 2010 at 4:19 AM, Mibu mibu.cloj...@gmail.com wrote: As far as I can tell, clj-sandbox works by a set whitelist of arbitrary functions, which is not a very generic approach. It works for sandboxes like clojurebot, but not for other stuff. A restricted eval in all likelihood will not refer directly to clojure.core, and it's much better allowing the caller to specify by namespaces which functions are accessible. Maybe in the future clojure.core functions could be tagged depending on whether they are purely-functional or have side-effects, and a caller to a restricted eval will be able to automatically generate a new safe-core namespace based on this division. While we are talking about sandboxed eval, it is not just which function is accessible but also things like .alterRoot which becomes a instance method of a java object which goes a bit beyond clojure name space. with some clever tricks, it is possible to get the var of a root binding then .alterRoot and replace the definition. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Restricted eval
On Thu, May 6, 2010 at 10:49 AM, Heinz N. Gies he...@licenser.net wrote: If I may :) since I'm the sandbox guy. Is it possible to use the sandbox functionalities without the future/thread part ? Basically, I am trying to create a chatty REPL(say HTTP POST based). the thread would be created by the app container and the container already has its own protection against endless loop style attack or other typical restrictions for a web based application. I just want to ensure that each thread runs within its own namespace and would not be able to get into the neighbour namespace(or other shared/referred namespaces like clojure.core) and do a .alterroot style thing. But if possible, still be able to use most clojure features. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: last-var-wins: a simple way to ease upgrade pain
I have a question related to this. (ns foo (:use clojure.core)) (defn + [x y] x) '+' is already referred because of the use and is an error right now. But this is a legitimate use of the symbol as 'foo' can be matrix and matrix addition is different from standard number addition. Or is there a better for these kind of primitive symbols overload in clojure or symbol overload in general ? :exclude may not be what I want here as I may still call for the basic + on numbers. In Haskell for example, this is not an issue because of its type class support so I can have multiple '+' doing different 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: last-var-wins: a simple way to ease upgrade pain
On Wed, May 5, 2010 at 3:18 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Wed, May 05, 2010 at 02:56:09PM -0700, gary ng wrote: Right now, this can be handled as: (ns foo (:refer-clojure :as core :exclude (+))) (defn + [matrix1 matrix2] ... (core/+ num1 num2) ...) Thanks. though it is still a bit limited in the sense that in each ns, there can only be one implementation of a symbol, though I think that is the characteristic of all symbol based dynamic language. I am writing a toy DSL where I would like it to be able to do something like this: (+ today 3) = a date which is 3 days from today (+ 1 2) = 3 such that the following is possible (+ today (- 14 remind-prior)) = 2 weeks from today - a fixed remind before days = a date when I am going to be reminded for an event 2 weeks from today -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: what is wrong with (use `clojure.contrib.string) ?
On Thu, Apr 29, 2010 at 10:43 PM, David Nolen dnolen.li...@gmail.comwrote: My rule of thumb is: use + :only require + :as I believe this should be documented as the 'suggested usage'. As contrary to Python where 'from module import *'(which is 'use' in clojure) is right in there saying 'you know what you are doing', clojure's use is inviting for newbie(import for java, use for clojure module) but it really should only be used sparsely or qualified with [:only] Another thing that is a bit confusing is the form different between (ns [:use ...]) vs naked (use ...). Sometimes, not putting into a vector works, sometimes it doesn't. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
what is wrong with (use `clojure.contrib.string) ?
Clojure 1.2.0-master-SNAPSHOT user= (use `clojure.contrib.string) java.lang.IllegalStateException: repeat already refers to: #'clojure.core/repeat in namespace: user (NO_SOURCE_FILE:0) By going through the source, I see c.c.s deliberately exclude certain symbols but don't know how to do it in the REPL. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: what is wrong with (use `clojure.contrib.string) ?
On Thu, Apr 29, 2010 at 7:24 PM, ataggart alex.tagg...@gmail.com wrote: user= (defn repeat [x] x) java.lang.Exception: Name conflict, can't def repeat because namespace: user refers to:#'clojure.core/repeat (NO_SOURCE_FILE:1) user= (ns my.ns (:refer-clojure :exclude [repeat])) nil my.ns= (defn repeat [x] x) #'my.ns/repeat thanks. Though I found this behavior a bit annoying. What seems to be happening is that I need to exclude all the symbols that is excluded by c.c.string again if I use 'use ...' why would 'repeat' all of a sudden appear again if it is excluded from c.c.string ? does it mean I need to go through the source each time if I encounter such error ? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: what is wrong with (use `clojure.contrib.string) ?
On Thu, Apr 29, 2010 at 9:11 PM, Meikel Brandmeyer m...@kotka.de wrote: c.c.string is not designed to be used like that. Use require plus an alias: (require '[clojure.contrib.string :as s]). Then repeat is the core repeat and s/repeat is the string repeat. What would be the use case of 'use' then ? As this is not the first time I have encountered this kind of symbol conflict. So naturally, I would follow your advice of using require and ':as'. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Any window user familiar with clojure-contrib development ?
Hi, I am wondering if there is any windows user who is familiar with clojure-contrib project. The reason I asked is that I encountered quite some issues when trying to build my own copy of clojure-contrib(on windows). That includes: 1. I cannot clone http://github.com/richhickey/clojure-contrib.git as it would die in the middle for some item(i.e. certain git hash object) not found. I have to use git:// instead 2. Even after successful cloning, certain files seems to be suffering from the CRLF/LF conversion issue, I have to turn off git's CRLF auto conversion or else the newly cloned tree would already been showing changes(while the diff shows lines deleted then added with no noticeable difference, which I traced to the CRLF). 3. Then while building clojure-contrib, certain tests failed which based on the test log is again about the odd case of file system naming(file:/foo 'file://C:/foo) and CRLF LF -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure.contrib.logging and Google App Engine
On Sun, Apr 25, 2010 at 4:47 PM, ataggart alex.tagg...@gmail.com wrote: Yeah, the fix-patch was submitted prior to the final release of 1.1.0, but alas none of those with the power to actually commit the patch got around to it until it was too late. I have built the 1.2.0-snapshot which seems to be even worse as it is now throwing exception during the build process. BUILD FAILED java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at clojure.lang.RT.loadClassForName(RT.java:1550) at clojure.lang.RT.load(RT.java:379) at clojure.lang.RT.load(RT.java:361) at clojure.core$load__5214$fn__5221.invoke(core.clj:4394) at clojure.core$load__5214.doInvoke(core.clj:4393) at clojure.lang.RestFn.invoke(RestFn.java:409) at clojure.core$load_one__5155.invoke(core.clj:4222) at clojure.core$load_lib__5170.doInvoke(core.clj:4259) at clojure.lang.RestFn.applyTo(RestFn.java:143) at clojure.core$apply__3699.invoke(core.clj:480) at clojure.core$load_libs__5186.doInvoke(core.clj:4293) at clojure.lang.RestFn.applyTo(RestFn.java:138) at clojure.core$apply__3699.invoke(core.clj:482) at clojure.core$use__5210.doInvoke(core.clj:4371) at clojure.lang.RestFn.invoke(RestFn.java:409) at guestbook.xmppc$loading__5103__auto8.invoke(xmppc.clj:1) at guestbook.xmppc__init.load(Unknown Source) at guestbook.xmppc__init.clinit(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at clojure.lang.RT.loadClassForName(RT.java:1550) at clojure.lang.RT.load(RT.java:379) at clojure.lang.RT.load(RT.java:361) at clojure.core$load__5214$fn__5221.invoke(core.clj:4394) at clojure.core$load__5214.doInvoke(core.clj:4393) at clojure.lang.RestFn.invoke(RestFn.java:409) at clojure.core$load_one__5155.invoke(core.clj:4222) at clojure.core$compile__5226$fn__5227.invoke(core.clj:4404) at clojure.core$compile__5226.invoke(core.clj:4403) at clojure.lang.Var.invoke(Var.java:365) at clojure.lang.Compile.main(Compile.java:56) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217) at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152) at org.apache.tools.ant.taskdefs.Java.run(Java.java:764) at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:218) at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:132) at org.apache.tools.ant.taskdefs.Java.execute(Java.java:105) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) at org.apache.tools.ant.Project.executeTarget(Project.java:1306) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1189) at org.apache.tools.ant.Main.runBuild(Main.java:758) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) Caused by: java.lang.RuntimeException: Valid logging implementation could not be found. at clojure.contrib.logging$fn__37.invoke(logging.clj:188) at clojure.contrib.logging__init.load(Unknown Source) at clojure.contrib.logging__init.clinit(Unknown Source) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure.contrib.logging and Google App Engine
On Mon, Apr 26, 2010 at 6:26 PM, gary ng garyng2...@gmail.com wrote: On Sun, Apr 25, 2010 at 4:47 PM, ataggart alex.tagg...@gmail.com wrote: Yeah, the fix-patch was submitted prior to the final release of 1.1.0, but alas none of those with the power to actually commit the patch got around to it until it was too late. I have built the 1.2.0-snapshot which seems to be even worse as it is now throwing exception during the build process. BUILD FAILED java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at clojure.lang.RT.loadClassForName(RT.java:1550) at clojure.lang.RT.load(RT.java:379) at clojure.lang.RT.load(RT.java:361) at clojure.core$load__5214$fn__5221.invoke(core.clj:4394) at clojure.core$load__5214.doInvoke(core.clj:4393) at clojure.lang.RestFn.invoke(RestFn.java:409) at clojure.core$load_one__5155.invoke(core.clj:4222) at clojure.core$load_lib__5170.doInvoke(core.clj:4259) at clojure.lang.RestFn.applyTo(RestFn.java:143) at clojure.core$apply__3699.invoke(core.clj:480) at clojure.core$load_libs__5186.doInvoke(core.clj:4293) at clojure.lang.RestFn.applyTo(RestFn.java:138) at clojure.core$apply__3699.invoke(core.clj:482) at clojure.core$use__5210.doInvoke(core.clj:4371) at clojure.lang.RestFn.invoke(RestFn.java:409) at guestbook.xmppc$loading__5103__auto8.invoke(xmppc.clj:1) at guestbook.xmppc__init.load(Unknown Source) at guestbook.xmppc__init.clinit(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at clojure.lang.RT.loadClassForName(RT.java:1550) at clojure.lang.RT.load(RT.java:379) at clojure.lang.RT.load(RT.java:361) at clojure.core$load__5214$fn__5221.invoke(core.clj:4394) at clojure.core$load__5214.doInvoke(core.clj:4393) at clojure.lang.RestFn.invoke(RestFn.java:409) at clojure.core$load_one__5155.invoke(core.clj:4222) at clojure.core$compile__5226$fn__5227.invoke(core.clj:4404) at clojure.core$compile__5226.invoke(core.clj:4403) at clojure.lang.Var.invoke(Var.java:365) at clojure.lang.Compile.main(Compile.java:56) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217) at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152) at org.apache.tools.ant.taskdefs.Java.run(Java.java:764) at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:218) at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:132) at org.apache.tools.ant.taskdefs.Java.execute(Java.java:105) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) at org.apache.tools.ant.Project.executeTarget(Project.java:1306) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1189) at org.apache.tools.ant.Main.runBuild(Main.java:758) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) Caused by: java.lang.RuntimeException: Valid logging implementation could not be found. at clojure.contrib.logging$fn__37.invoke(logging.clj:188) at clojure.contrib.logging__init.load(Unknown Source) at clojure.contrib.logging__init.clinit(Unknown Source) Seems that the problem is deeper(well into the clojure compiler). I took out the catch_all and let the exception shows up Caused by: java.io.IOException: The system cannot find the path specified (NO_SOURCE_FILE:0) at clojure.lang.Compiler.analyzeSeq(Compiler.java:5285) at clojure.lang.Compiler.analyze(Compiler.java:5099
Re: idiomatic clojure of this java style ?
On Sat, Apr 24, 2010 at 12:56 PM, Allen Johnson akjohnso...@gmail.comwrote: Here's my attempt. I don't think you can do much about the imperative style when you are calling Java APIs unless someone was nice and wrote a clojure wrapper. But I'm just a n00b. thanks for the help. When deployed to GAE, I got the following exception related to the logging function. Just from browsing the logging code in clojure-contrib, it seems that the 'import should be catched and ignored, not sure why it happens. Error for /_ah/xmpp/message/chat/ java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at clojure.contrib.logging$fn__49$fn__51.invoke(logging.clj:188) at clojure.lang.AFn.applyToHelper(AFn.java:173) at clojure.lang.AFn.applyTo(AFn.java:164) at clojure.core$apply__4370.invoke(core.clj:436) at clojure.core$memoize__6537$fn__6539.doInvoke(core.clj:4328) at clojure.lang.RestFn.invoke(RestFn.java:413) at guestbook.xmppc$_doPost__16.invoke(xmppc.clj:31) at guestbook.xmppc.doPost(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:713) at guestbook.xmppc.service(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) at guestbook.xmppc.service(Unknown Source) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166) at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:97) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:238) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923) at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135) at com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:243) at com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:5838) at com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:5836) at com.google.net.rpc.impl.BlockingApplicationHandler.handleRequest(BlockingApplicationHandler.java:24) at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:398) at com.google.net.rpc.impl.Server$2.run(Server.java:852) at com.google.tracing.LocalTraceSpanRunnable.run(LocalTraceSpanRunnable.java:56) at com.google.tracing.LocalTraceSpanBuilder.internalContinueSpan(LocalTraceSpanBuilder.java:576) at com.google.net.rpc.impl.Server.startRpc(Server.java:807) at com.google.net.rpc.impl.Server.processRequest(Server.java:369) at com.google.net.rpc.impl.ServerConnection.messageReceived(ServerConnection.java:442) at com.google.net.rpc.impl.RpcConnection.parseMessages(RpcConnection.java:319) at com.google.net.rpc.impl.RpcConnection.dataReceived(RpcConnection.java:290) at com.google.net.async.Connection.handleReadEvent(Connection.java:474) at com.google.net.async.EventDispatcher.processNetworkEvents(EventDispatcher.java:831) at com.google.net.async.EventDispatcher.internalLoop(EventDispatcher.java:207) at com.google.net.async.EventDispatcher.loop(EventDispatcher.java:103) at com.google.net.rpc.RpcService.runUntilServerShutdown(RpcService.java:251) at
clojure.contrib.logging and Google App Engine
Hi, I am trying to use clojure to write servlets for GAE and is encountering problem with clojure.contrib.logging. When trying to use the logging function, I get the following exception: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:151) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at clojure.contrib.logging$fn__49$fn__51.invoke(logging.clj:188) at clojure.lang.AFn.applyToHelper(AFn.java:173) at clojure.lang.AFn.applyTo(AFn.java:164) at clojure.core$apply__4370.invoke(core.clj:436) at clojure.core$memoize__6537$fn__6539.doInvoke(core.clj:4328) at clojure.lang.RestFn.invoke(RestFn.java:413) at guestbook.servlet$_doGet__3.invoke(servlet.clj:15) Initially, I thought it is related to this http://www.assembla.com/spaces/clojure-contrib/tickets/44-AOT-compilation-of-clojure-contrib-jar-pre-sets-logging-implementationbut by examine the clojure-contrib-1.1.0.jar packaged, the logging.clj is clearly NOT pre-compiled and I lost why such error would occur. the (import org.apache.commons.logging ...) in logging.clj is wrapped in try/catch so should be silently ignored ? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure.contrib.logging and Google App Engine
On Sun, Apr 25, 2010 at 11:08 AM, gary ng garyng2...@gmail.com wrote: Hi, I am trying to use clojure to write servlets for GAE and is encountering problem with clojure.contrib.logging. When trying to use the logging function, I get the following exception: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:151) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at clojure.contrib.logging$fn__49$fn__51.invoke(logging.clj:188) at clojure.lang.AFn.applyToHelper(AFn.java:173) at clojure.lang.AFn.applyTo(AFn.java:164) at clojure.core$apply__4370.invoke(core.clj:436) at clojure.core$memoize__6537$fn__6539.doInvoke(core.clj:4328) at clojure.lang.RestFn.invoke(RestFn.java:413) at guestbook.servlet$_doGet__3.invoke(servlet.clj:15) Seems to find the reason. The GAE SDK does package org.apache.common.logging which means when I am 'gen-class' my servlet, it saw this and thus the logging is 'nailed' to use this class. But the runtime doesn't have it. I can fallback to use java.util.logging but see this to be a more common problem and don't know how to solve elegantly. What seems to be happening is that when I build my 'gen-class' package, the class is nailed down even though logging.clj itself is not gen-classed. Then how can I achieve this form of 'dynamic loading and configuration' as I do need gen-class for my servlet class and it is almost impossible to control what jar is visible during the development/build environment. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure.contrib.logging and Google App Engine
On Sun, Apr 25, 2010 at 1:17 PM, Allen Johnson akjohnso...@gmail.comwrote: What seems to be happening is that when I build my 'gen-class' package, the class is nailed down even though logging.clj itself is not gen-classed. I'm not familiar with GAE but as a workaround can you include the commons-logging.jar in your war file? Then configure commons-logging to delegate to java.util.logging. Thanks for the help and suggestion. Yes, though as I mentioned it is a more general problem than this particular case. I have gone through the patch of c.c.logging which now changed to use 'eval' to delay the loading(thus should solve the nailed down too early issue). This seems like a DI injection equivalent. The problem of shipping the commons-logging.jar is that I am getting into the the app container turf(say in the case they have their own google.logging). What if say I am using the JPA/JDO where my development environment is mysql and the runtime is something else ? In other words, all this 'try import ...' tricks should(?) be done in the latest patched way of using eval as there can be multiple build points along the path (the clojure-contrib build, my own build, could be some more build if I write a wrapper which also use c.c.logging and someone takes my wrapper, just like c.c.logging, then the final runtime). Just not sure what form of performance impact it carries(not that I care for this particular case). -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
idiomatic clojure of this java style ?
Hi, As a newbie learning clojure, I would like to code in clojure rather than 'java disguised as clojure' and I am wondering what would it looks like for the following typical java(shown below) implementation. which has: 1. a static class member for the logger 2. and typical imperative style coding = public class xmpp extends HttpServlet { public static final Logger _log = Logger.getLogger(xmpp.class.getName()); @Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { try { String strStatus = ; XMPPService xmpp = XMPPServiceFactory.getXMPPService(); //STEP 2 Message msg = xmpp.parseMessage(req); JID fromJid = msg.getFromJid(); String body = msg.getBody(); _log.info(Received a message from + fromJid + and body = + body); //STEP 3 String msgBody = You sent me : + body; Message replyMessage = new MessageBuilder() .withRecipientJids(fromJid) .withBody(msgBody) .build(); //STEP 4 boolean messageSent = false; SendResponse status = xmpp.sendMessage(replyMessage); messageSent = (status.getStatusMap().get(fromJid) == SendResponse.Status.SUCCESS); //STEP 5 if (messageSent) { strStatus = Message has been sent successfully; } else { strStatus = Message could not be sent; } _log.info(strStatus); } catch (Exception e) { _log.log(Level.SEVERE,e.getMessage()); } } -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: Which version of Netbeans to use Compojure on OSX?
I would choose the one with glassfish which includes the web app things that even though you may not need immediately(if compojure comes with embedded jetty) will be very likely in the future when you use other app containers(be it GAE or tomcat etc.) I picked the base Java SE version and needs to add the web application stuff back later because I am working on project to push to GAE. BTW, there is no web application support in enclojure. On Wed, Apr 21, 2010 at 4:55 PM, Sophie itsme...@hotmail.com wrote: I see downloads named - Java SE (45MB) - Java FX (76MB) - Java (146MB) - apparently includes Sun Glassfish Server what-not I'm using OSX 10.5.8, and just want to install the easiest Netbeans (with Enclojure) to for development with Compojure. Would I use Compojure with Jetty? Apache (built into OSX)? 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.comclojure%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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Erlang like environment
Hi, I just start to learn about clojure and is wondering if there is any erlang like environment for clojure ? By that, I mean not just the messaging passing(which as far as I can tell for clojure is within the same process) but its live update and sending symbols(and as far as I know functions as well) across process/vm instances(which can be on the same machine or another machine within a private network). -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe, reply using remove me as the subject.