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

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 are

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

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

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

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

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: 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: 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 calculated. So

keyword bug

2013-04-14 Thread ubun2
(keyword m 7) ;;= :m/7 :m/7 ;;= #RuntimeException java.lang.RuntimeException: Invalid token: :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

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

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 April

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: 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 libraries

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

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: 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

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 you

Re: - operator and monads

2013-04-14 Thread Ben Wolfson
On Sun, Apr 14, 2013 at 1:03 PM, Marko Topolnik marko.topol...@gmail.comwrote: 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

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: 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 metadata,

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:

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

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 and

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: 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

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) #Namespace 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: 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

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 https://github.com/RyanMcG/Cadence of mine. It works just fine on Heroku. Originally it was a noir/jetty application which I have since moved to

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) #Namespace m m= (clojure.core/keyword m 7) :m/7 m=

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 marko.topol...@gmail.com On Monday, April 15, 2013 2:50:11 AM UTC+2, David Della Costa wrote: If you give keyword two