Re: Good Clojure style?

2013-04-14 Thread edward
Thanks everyone- that's been really useful. And yes, frequencies, really throws me every time (as do some of the unintuitively - to me - named functions). On Wednesday, 10 April 2013 18:27:58 UTC+1, edw...@kenworthy.info wrote: > > So, page 143 of Clojure Programming has an implementation of Con

Re: Good Clojure style?

2013-04-14 Thread edward
Haha! I had similar advice from my Grandfather in the late 70s who predicted that computers will be writing all their own programs in the near future and so the job prospects for working in the field would be quite poor. On Sunday, 14 April 2013 09:52:46 UTC+1, Korny wrote: > > I've been forget

Re: Good Clojure style?

2013-04-14 Thread edward
I'm sorry but that's not true. The version over the page hasn't been re-factored 'into a nicer version' it's been re-factored into a more generic version to support, for example, hexagonal grids. On Saturday, 13 April 2013 23:12:59 UTC+1, Tj Gabbour wrote: > > Hi, > > The text explains the "eleg

Re: Problems loading Clojure core in Nutch plugin

2013-04-14 Thread Michael Richman
Hi Michael, I'm having an identical issue with a different jar (not Nutch related) and I wonder if you ever figured this out. Thanks, Michael @ Bitly -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@go

Re: keyword bug

2013-04-14 Thread Andy Fingerhut
The description of legal symbols at http://clojure.org/reader could be somewhat more explicit on this. One could read it to mean that since :m/7 starts with an non-numeric "m" after the :, it is legal. One could also infer from it that since within namespace m you could not use :7 (since that sta

Re: keyword bug

2013-04-14 Thread David Della Costa
Ah, my mistake, apologies for adding noise. In that case, not sure what to say...I'll let someone with better knowledge of Clojure internals respond. 2013/4/15 Marko Topolnik > On Monday, April 15, 2013 2:50:11 AM UTC+2, David Della Costa wrote: > >> If you give keyword two arguments the first

Re: keyword bug

2013-04-14 Thread Marko Topolnik
On Monday, April 15, 2013 2:50:11 AM UTC+2, David Della Costa wrote: > If you give keyword two arguments the first one is the namespace, and > you are generating a namespaced keyword. To expand on your example: > > clojure.core=> (in-ns 'm) > # > m=> (clojure.core/keyword "m" "7") > :m/7 >

Re: http-kit on heroku?

2013-04-14 Thread Wei Hsu
Thanks guys, got it sorted out. If I may ask a followup question, how do you run it in development? Pre-http-kit, I've been using lein ring server, which has a nice feature that reloads code automatically as it is saved so you don't have to restart the server. On Sunday, April 14, 2013 8:39:50

Re: http-kit on heroku?

2013-04-14 Thread Ryan McGowan
Maik is right. However, if you still want an example application you can check out a side project of mine. It works just fine on Heroku. Originally it was a noir/jetty application which I have since moved to http-kit

Re: Namespaces, APIs, protocols and records

2013-04-14 Thread Mikera
You may want to look at what core.matrix does in this regard: clojure.core.matrix: single namespace containing the public API clojure.core.matrix.protocols: namespace containing all the protocols clojure.core.matrix.impl.* : namespaces for specific implementations / subsystems + a few utility nam

Re: keyword bug

2013-04-14 Thread Dave Della Costa
If you give keyword two arguments the first one is the namespace, and you are generating a namespaced keyword. To expand on your example: clojure.core=> (in-ns 'm) # m=> (clojure.core/keyword "m" "7") :m/7 m=> {::7 "foo"} {:m/7 "foo"} m=> If you want to chain strings together to make a keyword,

Re: Head retention example

2013-04-14 Thread tyaakow
Thank you for your response, Marko. I want to clarify one more thing: (let [[t d] (split-with #(< % 12) (range 1e8))] [(count d) (count t)]) does this mean that while (count d) is realizing (range 1e8) seq, it becomes (also) realized within t, therefore it doubles (range 1e8) in memory cau

Re: [ANN] Instaparse 1.0.0

2013-04-14 Thread Dmitry Kakurin
Interesting, I did not know that. That's OK if checks do not *guarantee* correctness. But having 20/80 Pareto principle in mind: if few simple detection technics will warn about 80% of ambiguous grammars (especially the ones found in practice), that would be very helpful. Thanks, Dmitry. -- --

Re: Memoization in clojure

2013-04-14 Thread Jonathan Fischer Friberg
> > Oops ;) > Of course you are right. The amazing thing is that the times I observed > fitted somehow the situation (the first (fib 30) call taking much more time > than the others, the third call more than the second and fourth) that I was > tricked into believing the calculations were being done

Re: [ANN] Instaparse 1.0.0

2013-04-14 Thread Brandon Bloom
Thanks for the details. You definitely made the right pragmatic decision. What you've said pretty much matches what I expected to hear, although I'm hopeful that the approach can be refined, since it's quite eloquent. Beyond eloquence, the derivatives approach is also interesting for schema val

Re: Is conj supposed to preserve metadata?

2013-04-14 Thread Max Penet
Nevermind, I just noticed it was marked to be applied in 1.5. On Sunday, April 14, 2013 11:36:45 PM UTC+2, Max Penet wrote: > > into doesn''t preserve metadata (clj-1.4). > > > (meta (into (with-meta {} {:foo :bar}) {})) > nil > > There was an Issue about it, but it was closed: > http://dev.cloj

Re: Is conj supposed to preserve metadata?

2013-04-14 Thread Max Penet
into doesn''t preserve metadata (clj-1.4). > (meta (into (with-meta {} {:foo :bar}) {})) nil There was an Issue about it, but it was closed: http://dev.clojure.org/jira/browse/CLJ-916 On Sunday, April 14, 2013 11:01:26 PM UTC+2, Marko Topolnik wrote: > > Yes, it is meant to preserve metadat

Re: Is conj supposed to preserve metadata?

2013-04-14 Thread Marko Topolnik
Yes, it is meant to preserve metadata, as well as all other core functions of such kind. Clojure is dedicated to doing the right thing with metadata wherever there is an obvious "right thing" to do. If you find a case where it doesn't preserve meta, you probably have a bug to report. -marko On

Re: -> operator and monads

2013-04-14 Thread Ben Wolfson
On Sun, Apr 14, 2013 at 1:03 PM, Marko Topolnik wrote: > On Sunday, April 14, 2013 7:51:10 PM UTC+2, Matthew Hill wrote: > >> Function composition is done via comp. Using -> and ->> is like function >> composition in reverse order (though there's a difference between how the >> two thread return v

Is conj supposed to preserve metadata?

2013-04-14 Thread JvJ
I've noticed that the conj operation seems to preserve metadata in most cases: >(meta (conj (with-meta [] {:a 1}) 5)) {:a 1} However, I'm not sure if this is something I can depend on, or if it's just a fluke. Is this "part of the spec", as it were? -- -- You received this message because yo

Re: Memoization in clojure

2013-04-14 Thread Paulo Sérgio Almeida
On Sunday, April 14, 2013 5:30:13 PM UTC+1, Jonathan Fischer Friberg wrote: Calling fib just creates a new function, no values > are calculated. So you're measuring the time > it takes to create a function, and not the calculation > of fibonacci numbers. > > Oops ;) Of course you are right. The

Re: -> operator and monads

2013-04-14 Thread Marko Topolnik
On Sunday, April 14, 2013 7:51:10 PM UTC+2, Matthew Hill wrote: > Function composition is done via comp. Using -> and ->> is like function > composition in reverse order (though there's a difference between how the > two thread return values), and often it reads more naturally. -> applies the

Re: http-kit on heroku?

2013-04-14 Thread Maik Schünemann
I don't have an example of deploying http-kit on Heroku, but I think it should be straightforward - basically your local setup should work on heroku. Just like you can deploy your application, which starts up jetty to heroku I think you can deploy your http-kit application on heroku. The only think

Re: Namespaces, APIs, protocols and records

2013-04-14 Thread Simon Katz
Whoops — when I said "with an extra [namespace] for each protocol", I meant "with an extra [namespace] for each protocol implementation". On Sunday, 14 April 2013 18:21:19 UTC+1, Simon Katz wrote: > > I'm in the process of trying to work out how I want to use namespaces when > implementing libra

Re: Head retention example

2013-04-14 Thread Marko Topolnik
On Sunday, April 14, 2013 2:58:55 AM UTC+2, tyaakow wrote: > I'm reading Clojure Programming book by O'Reilly.. > > I came over an example of head retention. First example retains reference > to d (I presume), so it doesnt get garbage collected: > > (let [[t d] (split-with #(< % 12) (range 1e8))]

Re: -> operator and monads

2013-04-14 Thread Matthew Hill
Function composition is done via comp. Using -> and ->> is like function composition in reverse order (though there's a difference between how the two thread return values), and often it reads more naturally. user> (-> [1 2 5] rest first) 2 user> ((comp first rest) [1 2 5]) 2 On Wednesday, 3 Ap

Namespaces, APIs, protocols and records

2013-04-14 Thread Simon Katz
I'm in the process of trying to work out how I want to use namespaces when implementing libraries or subsystems. I'm aware of several approaches: - Use a single namespace, making only the API public (either with everything in a single file or breaking things into multiple files and us

keyword bug

2013-04-14 Thread ubun2
(keyword "m" "7") ;;=> :m/7 :m/7 ;;=> # a bug right? -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your firs

Re: Memoization in clojure

2013-04-14 Thread Jonathan Fischer Friberg
> > (letfn [(fib [x] > (memoize > #(if (or (zero? %) (= % 1)) >1 >(+ (fib (- % 1)) (fib (- % 2))] > (time (fib 30)) > (time (fib 30)) > (time (fib 40)) > (time (fib 40))) > Calling fib just creates a new function, no values are calc

Re: Memoization in clojure

2013-04-14 Thread Paulo Sérgio Almeida
Another problem with (def fib (memoize ...)) for tight recursion patterns with little code is the cost of accessing the var itself, which may also prevent further optimizations. To restrict the scope of memoization and obtain both simplicity and even more efficiency: (letfn [(fib [x]

Re: Good Clojure style?

2013-04-14 Thread Softaddicts
Nope, it's not an absolute age limit issue. It's more a question of your peak throughput. I am still faster than my customer's employees these days but the ratio had dropped when I was around 40 compared to what it was at 30. I was still rooted in the Java world, to my own despair. This survey

Re: Good Clojure style?

2013-04-14 Thread Gary Trakhman
I started writing clojure full-time a year and a half ago. At first, it was a terrifying freedom that I could only write a few lines of code a day, and each line was so packed with meaning it makes your head spin. It took an incredibly long time to understand the terseness of code. Maybe some

Re: Good Clojure style?

2013-04-14 Thread Mimmo Cosenza
Hello all, may I ask a very simple private question? How old is Rich? I suspect that, by following some statements in this thread, he should have already refrained himself from programming few years ago, perhaps before he invented Clojure. mimmo I'm very biased, being 52 years old On Apr 14

Re: Good Clojure style?

2013-04-14 Thread Chris Webster
Uh, Luc, are you suggesting anybody over the age of 30 can't code productively any more? Because it sure sounds like that. If so, that seems like a curiously ageist argument to make in a Clojure thread. I'll leave it to the legions of skilled and productive programmers over 30 to contradict t

Re: Good Clojure style?

2013-04-14 Thread Tj Gabbour
I've always been awful at finding my keys, and rarely remembered if yesterday's events were really three days ago. :) Being told to accomplish rote tasks is gloomy, and I have to figure out how to internally motivate myself. I've met many like me. Who knows the interpretation? Maybe a charitabl

Re: Good Clojure style?

2013-04-14 Thread Marko Topolnik
On Saturday, April 13, 2013 9:42:29 PM UTC+2, da...@axiom-developer.org wrote: > > > Inevitably I get rejected because I'm "overqualified", which is > l33t speak for "old". Would you reject a builder, pilot, or lawyer > for being "overqualified"? > They would, and for the same reasons, which

Re: Good Clojure style?

2013-04-14 Thread Korny Sietsma
I've been forgetting my car keys consistently for the last 20 years - but now I'm in my mid 40s it's easy to blame it on ageing :-) I've been coding for longer than I've been losing car keys, and I can't say I've noticed a lot of decline. As for the lack of grey beards at conferences (mentioned el