Re: Pattern of Succinctness
On Aug 12, 2012, at 12:38 PM, Tamreen Khan wrote: (filter #(not (nil? %)) coll) (filter identity coll) ;; nearly equal Is the last one considered generally more readable? I think the following is clearer while still not having as much noise as the first filter example: (filter (partial not nil?) coll) To me it is. I read/heard somewhere that the identity check was idiomatic, and started using it to the point where I find myself saying filter identity as slang for keeping only the valid things. but that's just me (maybe)... don't know that it is generally considered more readable (but I think so). bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How to speed up Clojure Training for New Recruitment
On Jun 18, 2012, at 2:11 AM, Murtaza Husain wrote: Hi, Just wanted to get pointers on how do you manage the training of recruits. It is difficult to find clojure talent, I don't hire based on knowledge, I hire based on ability/desire to *learn*. For senior people I also want the same ability/desire to share what they've learned with others. How can the learning curve, and training time be reduced for new recruits ? Put them on teams full of people who like to learn and to teach and tell them their 1st job is to learn, not to ship code so get cracking. Oh, and I also believe training is mostly a waste of resources. Training is pushing information. Learning is a self-directed activity. I look for people who would be bored stiff in training (a good sign is if they work ahead of the trainer and otherwise break the class). Also how do you pitch it to the management ? Point out how well the other ways have been working out for the industry. bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How to speed up Clojure Training for New Recruitment
On Jun 18, 2012, at 6:37 AM, Murtaza Husain wrote: Bill that is very interesting. So how do you make them learn. Haha, I don't make anyone do *anything* on my team (I'm not exaggerating). My first (and more or less last) directive as team-lead is to declare it a team of peers. We ask people to join us who want to do what's needed for us to succeed. At most we will explain that the team uses clojure (and javascript and ruby, and something new when we need it) and if they aren't *eager* to learn new things to solve problems (and that's obvious in about 30 seconds of interviewing), there's no point in wasting our time. Do you pair them up with someone who knows on some task? I mean how do you structure learning ? If this stuff was reducible to rules, you wouldn't need learners, you could do the whole training bit - maybe even write a program to write code for you. Hire people who like to learn, put them on the team. That's it. The team figures it out from there (i.e. different in each case, based on personalities, languages, tasks, goals, current deadlines, etc.) Bcoz as you mentioned that put them into a team where everyone likes to share, however everyone may be working on things above them, If getting this person up to speed is important for team's success, there is nothing above them... there is only velocity. If velocity is more important than learning, the ramp-up time will be longer... if the wider organization values speed over competence, you'll get shitty code (that's not a learning clojure issue). and they may not be able to grasp, and they may also not have time. If either of these are true - and we made the mistake of asking them to join our team - they wouldn't be around long enough for it to matter. bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: why String is not a collection (of Character)
On Jun 8, 2012, at 2:21 AM, Cédric Pineau wrote: 2012/6/8 Cédric Pineau cedric.pin...@gmail.com 2012/6/8 Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com No. I assume you mean seqable. If it did exist, it would look something like: Is there a simple test for sequable? Oh ok, I don't get the difference between seq and seqable.. I think I got it : (seqable? a) check if a can be transform into a seq (seq? a) check if a _is_ a seq Sorry for the noise :-) Not noise - you helped me get the distinction (and thus the thread) and so on behalf of all of us, quiet and clueless: I salute you :-) bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: (#({:a %}) :b)
On Jun 3, 2012, at 8:53 PM, Steven Obua wrote: The expression (#({:a %}) :b) either: (#(hash-map :a %) :b) ((fn [x] {:a x}) :b) will work instead. Someone with more knowledge than me can probably explain better, but my understanding is that the the reader macro shorthand for anonymous functions and the map literal syntax can't both be used together (i.e. it's not a bug, but a reader limitation). bill should evaluate to {:a :b}, but raises an exception instead: Wrong number of args (0) passed to: PersistentArrayMap This is a pretty irritating bug and makes the #% form essentially unusable for me, because I cannot rely on it but have to always second guess if its use is safe in the current context or not. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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 %}) :b)
On Jun 3, 2012, at 9:35 PM, James Reeves wrote: On 4 June 2012 03:00, Bill Caputo logos...@gmail.com wrote: Someone with more knowledge than me can probably explain better, but my understanding is that the the reader macro shorthand for anonymous functions and the map literal syntax can't both be used together (i.e. it's not a bug, but a reader limitation). It's actually because #({:a %}) is equivalent to (fn [x] ({:a x})), when he wants (fn [x] {:a x}). So it's not a bug, nor a reader limitation, but rather a misunderstanding of what #() is short for. Ahh, that makes a lot more sense. Another foggy understanding clarified :-) bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: when function
On May 21, 2012, at 10:54 AM, Christian Guimaraes wrote: I'm struggling with when code structures and my imperative mindset. What is the better approach (or functional approach) to work with a code like the below? I think you're looking for cond (from memory, syntax might be wrong): (defn parse-group [group-identifier line] (cond (= group-identitifer ID1) (handle-id1 line) ... :else (do-something))) etc (doc cond) will give you what you need I think bill (defn parse-group [group-identifier line] (when (= group-identifier ID1) (handle-id1 line)) (when (= group-identifier ID2) (handle-id2 line)) (when (= group-identifier ID3) (handle-id3 line))) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: defrecord with inheritance
On May 20, 2012, at 4:23 PM, Warren Lynn wrote: defrecord, deftype, and defprotocol provide extensible low level abstractions like the kind Clojure is built on. As a Clojure programmer you should only need them rarely. As a beginner you should never use them. Well, I don't want to be a beginner for too long, :-) I am not a clojure beginner (though far from feeling I know all there is to learn about it). I have been using clojure for almost a year; my team has rebuilt the central part of our system (which is relied on by just about every other team where I work) out of clojure and have had it in production for 6 months. I've yet to even learn *how* to use defrecord, deftype defprotocol. IMO, If you're not doing a lot of java interop (i.e. where your clojure code is being consumed by java clients) you might never need them. As someone who came from, C++, C# Ruby (and a little Java) - i.e. OO - to clojure FP, I *strongly* recommend that you take a project (preferably one that you aren't hanging your livelihood on, but trust me it's a real rush) and try *really* hard to solve your design problems just with maps, vectors and the other core data structures (I first tried this in ruby, btw - a great learning experience and gave me a strong appreciation for the optimizations that clojure provides to make such code practical). IOW: pretend for a project that OO doesn't exist. When you're done, you'll have learned a lot, you'll still have what you know about OO, and when you're done you'll have lost nothing except your time and your perspective. You'll be doing yourself an enormous disservice if you simply try to map clojure onto your current way of working/thinking. bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how to get good at clojure?
On May 7, 2012, at 7:48 PM, toan wrote: 1. does anyone have advice on getting somewhat competent for a newb? (alternatively, how did you get good?) Can't recommend 4clojure ( http://www.4clojure.com/ ) highly enough; work through each one, turn on the code golf feature, and subscribe (at least) to those who've done all of them (so you can see how they did each puzzle) and you'll have a lot of idiomatic clojure learning at your fingertips. bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojurewest talk videos?
Alex, I never signed the release (my apologies) - but I'm fine with it... any alt. release I can provide? Bill - On Mar 19, 2012, at 9:33 AM, Alex Miller a...@puredanger.com wrote: Yes, all talks were recorded and will be released on http://infoq.com starting in about 3 weeks on a rolling basis. Alex On Sunday, March 18, 2012 1:12:41 PM UTC-5, Las wrote: Hi, will the videos of the talks be available for those who did not make it to the conference? thx -- László Török -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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.3 updated cheatsheet with links to clojuredocs.org
On Feb 27, 2012, at 1:22 AM, Andy Fingerhut wrote: Thanks to several people who provided feedback, especially Steve Miner, and to Alex Miller for updating the web site yet again, there is a new cheatsheet at: This is fantastic guys... thank you. One question: if one wants to help out with docs, how best to get involved? bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about this little method I wrote
Here's a version that uses destructuring (but is otherwise the same) that cleans it up a bit: (defn combinations [[x xs]] (if xs (for [frstitems x tlitm (combinations xs)] (flatten (list frstitems tlitm))) x)) On Feb 26, 2012, at 9:45 PM, Mike Ledoux wrote: (defn combinations [items] (if (== (count items) 1) (flatten items) (for [frstitems (flatten (first items)) tlitm (combinations (rest items))] (flatten (list frstitems tlitm) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from 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: - and -
On Feb 8, 2012, at 10:16 AM, Simon Holgate wrote: Could anyone point me to a description of - and -, please? Another thing to check out is Fogus' nice write up (and links) about these and other thrushy combinators: http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/ bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: SoftCaching in core.cache
On Feb 2, 2012, at 4:47 AM, Teemu Antti-Poika wrote: On Feb 1, 7:01 pm, Bill Caputo logos...@gmail.com wrote: We are looking to add soft-reference based caching to one of our applications and I was wondering if anyone could shed light on what the issues with clache's implementation were (i.e. is a total loss, or would it potentially be a good place for us to start, and so perhaps implement something that could be submitted back). I know nothing about core.cache's implementation, but I'd warn against relying on soft references for caching. I've seen out-of-memory exceptions due to this under heavy loads in one of our server applications. Thanks for the feedback, we'll be sure to test our use case thoroughly with that in mind... if other's are approaching fixed-size caching in closure differently, I'd love to hear more. bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
SoftCaching in core.cache
Hello All, Looking at the docs for core.cache: https://github.com/clojure/core.cache There is mention that support for SoftCache (caching using soft references) is not supported as the clache implementation was buggy and so not (yet) brought over. We are looking to add soft-reference based caching to one of our applications and I was wondering if anyone could shed light on what the issues with clache's implementation were (i.e. is a total loss, or would it potentially be a good place for us to start, and so perhaps implement something that could be submitted back). For background: Our ideal solution would be something like a LRU cache that had a fixed-memory constraint (e.g. some % of the total memory available to the box and/or JVM) so that we can minimize trips to the data store yet still ensure the application doesn't start paging due to too large a cache in an otherwise pretty simple/vanilla environment (i.e. no updates, read-only data). Also open to other approach than core.cache that are being used by others in the clojure community (e.g. wrapping ehcache or memcache-d, jcs etc). thanks, bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: SoftCaching in core.cache
On Feb 1, 2012, at 1:25 PM, Fogus wrote: Oddly enough it was leaking memory, but suspect it had to do with the queue reaper. I'd think that what's in Clache needs only a little work. Patches welcomed. Thanks, we'll likely take a look at it then. If we patch it, we'll send something along... bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Understanding the quoting of a symbol in a list
Hi All, So, I've been doing some experimentation in order to better understand the reader, and I can't figure out why I get the following results for these four calls: = ('foo); ((quote foo)) java.lang.IllegalArgumentException: Wrong number of args (0) passed to: Symbol (NO_SOURCE_FILE:0) = ('foo 1) ; ((quote foo) 1) nil = ('foo 1 2) ; ((quote foo) 1 2) 2 = ('foo 1 2 3) java.lang.IllegalArgumentException: Wrong number of args (3) passed to: Symbol (NO_SOURCE_FILE:0) What I expected is that either foo would be invoked (and so I'd see an error because it didn't exist) *or* I'd get a list ala (foo 1 2) - further, I can't understand why I get nil for an arity of 1 but 2 for an arity of two). Anyone have an explanation? I'm off to find the impl for Symbol and see if I can figure out how it is being invoked here... Thanks, Bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Understanding the quoting of a symbol in a list
On Tue, Jan 3, 2012 at 2:11 PM, JuanManuel Gimeno Illa jmgim...@gmail.com wrote: I'm not 100% sure but this is a side effect of the property that symbols can be used as functions that find themselves on maps. Thanks Juan Manuel - that's the thing I was missing (and thanks for the source link). bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Merging maps based on custom priority logic
On Sun, Dec 25, 2011 at 10:25 AM, Shoeb Bhinderwala shoeb.bhinderw...@gmail.com wrote: I want to merge lists of maps. Each map entry I have written the implementation. [...] Is there a more efficient, cleaner and idiomatic way to do this. Am I missing out on any core library functions that already provide this behavior? I believe the core function merge-with may give you what you are looking for: http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/merge-with bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Merging maps based on custom priority logic
On Sun, Dec 25, 2011 at 10:37 AM, Baishampayan Ghose b.gh...@gmail.com wrote: Shoeb wants to merge sequences of maps and not the maps themselves, so merge/merge-with won't help him much. Sorry, I may have misunderstood, I was thinking something like this (where select-code implements his selecting codes from two maps logic) : (apply merge-with #(if (= (:id %) (:id %2)) (select-code % %2) (merge % %2)) (concat p1 p2 p3 p4)) bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Implementing a clojure-only periodic timer...
On Dec 1, 2011, at 11:02 PM, Benny Tsai wrote: Overtone's 'at-at' library is a thin Clojure wrapper over ScheduledThreadPoolExecutor with a nice interface. I think you should be able to build a timer on top of it pretty easily. https://github.com/overtone/at-at Thanks Benny; I went with the approach that gaz suggested as it's exactly what I needed -- however any excuse to play with anything related to overtone is +1 :-) bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Implementing a clojure-only periodic timer...
Hi All, I am currently considering an approach similar to the following for periodically sending an update to an agent and I'm looking for feedback on whether there is anything wrong with it, whether it's idiomatic clojure (sorry I'm in the pro-that-term camp) and whether there are other pure-clojure alternatives I should consider (I also realize there are java-based periodic timers I could use as well): (def *timer* (agent nil)) ; perhaps an atom instead? (defn start-timer [ms a f] (letfn [(tfn [m] (future (do (Thread/sleep ms) (send a f) (send *timer* tfn] (send *timer* tfn))) given an agent: (def data (agent 0)) we could kick off an update every 3 seconds thusly: (start-timer 3000 data #(inc %)) A real implementation would likely have to address further considerations like stopping/cancelling the timer, not using a global for the timer, and what happens if start-timer is called twice, but this is the basic idea I'm considering... feedback welcome, thanks, bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Implementing a clojure-only periodic timer...
On Dec 1, 2011, at 11:45 AM, gaz jones wrote: Hey Bill, I would have thought you would have to have a pretty good reason for not using an executor for this? Just that I really never spent much time as a Java programmer, so evaluating the merits/tradeoffs/gotchas of using native (and 3rd party) Java libs from clojure is another level of complexity that I've been avoiding unless a clojure-only approach/library is deficient in some way. IOW - my heuristic has been to try for a clojure-only solution before looking at Java because that's a pretty big ocean of stuff to comb through... That said, I'm not *opposed* to using Java directly either - and it sounds like using an Executor might be an example of the if Java ain't broke, don't fix it approach that clojure takes and thus more or less idiomatic, so I'm fine with going that route if that's the case. In short: thanks for the answer gaz... bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Lookup on a symbol?
On Nov 24, 2011, at 12:32 AM, Sean Corfield wrote: @lloyda2 posted on Twitter: (reduce 'and '(false true)) = true ...Huh? I must admit, it looked odd to me... but I realized (after some REPL experimentation) this seems to be equivalent to ('some-symbol :some-key :some-default) I saw the tweet too - and after experimenting in REPL - replied to it that in this case 'and is just a symbol and 'foo works just the same. Can someone provide a bit more insight into why clojure.lang.Symbol behaves like a collection and what, if any elements does it have? Also interested in learning more, but I concluded (erroneously?) that it is false that is being indexed into: (:a false) returns nil as does ('and false) and (get false 2); I assumed it was so that it would fail gracefully if encountered where a collection was expected. bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en